Publishing and Searching Page ID

No comments Leave a comment »
For our Technology Services site we wanted the pages to be published as "1234.html" where "1234" is the page id number. This can be set up in SmartTree under General Settings. I also placed an info placeholder in each of the articles to have a page reference of that article number.

To make use of the article numbers we wanted to create a search where the user could enter the page id number and be taken directly to the article page. To do this we created a bit of ajax that is looking for a numeric file name which ends in html.

My first step was to create a dynamically populated list of page ids. I did this using a rendering of the navigation within a new template that I called search.xml. The ajax will pull it's information from this xml file.

content class =
<url><%!! Context:CurrentIndex.GetUrl() !!%></url><navigation:nextlevel>

Then I created a nav area and placed this within a page to be automatically rendered as pages are added:

<url_list>
<url>kb/blackboard/856.html</url>
<url>kb/blackboard/862.html</url>
<url>kb/blackboard/861.html</url>
<url>kb/blackboard/860.html</url>
<url>kb/blackboard/858.html</url>
<url>kb/blackboard/857.html</url>
</url_list>

I am using jquery to run this search, so initally I made a link to a jquery file.

Within the header I added the following jquery scripts. It searches for a numeric value, if that value is part of the xml document then the user is redirected to the desired page. If it is a numeric value that does not match the xml document, an error is returned. If the search term is not a number then the term is searched in the google search.

<script type="text/javascript">
$(document).ready(function() {

var searchVal;
var found;

var options = {
beforeSubmit: function(formData, jqForm, options) {
var form = jqForm[0];
searchVal = form.query.value + ".html";

},
success: function(responseText, statusText) {

$(responseText).find("url").each(function() {
var url = $(this).text();
if (url.match(searchVal + "$") == searchVal) {
window.location = url;
found = true;
}
});

if (!found) {
alert("Page not found. Please enter a new search term.");
}

}
};

$("#searchForm").submit(function() {
$(this).ajaxSubmit(options);

return false;
});

});

</script>


Here is the code for the form.

<form id="searchForm" action="search.xml">
Enter search term:
<input type="text" name="query" />
<input type="submit" />
</form>


About This Entry

Published on Monday, April 20 2009 at 05:10 PM by Tiffany France in the WebCMS (OpenText Management Server) blog.

Need Help?

If you need immediate assistance, please contact the Help Desk at (804) 828-2227 or submit a ticket online. You can also submit feedback through our Feedback form above or leave a comment on specific blog entries.

Don't Get Phished

Don't be a phishing victim - VCU and other reputable organizations will never use email to request that you reply with your password, social security number or confidential personal information. Learn more about phishing »

No comments below.

There are currently no comments. Be the first to respond.

Add your thoughts