Hi Chau, this functionality is actually available in Umbraco by utilizing the Ultimate Picker datatype. Take a look under Developers/Data Types in your Umbraco installation.
I assume it's for your website frontend and not for Umbraco Admin.
There's at least 2 good ways of doing this:
the Umbraco Base+jQuery way requires you to now the ways of .net coding
the XSLT + jQuery way
Also .. you could go and do a usercontrol but that seems like overkill when all you do is retrieve information.
The XSLT + jQuery way you'll need to:
1. Create an xslt file that renderes the output by traversing some umbraco nodes. Just let it return the markup fragment you need. Like <ul>...</ul>. Make the macro accept a parameter and let your code filter the nodes on this.
2. Add this macro to a template, example "ajaxsearch"
3. Create another template that should render your page. You could use the runway textpage. Add jquery reference, a input field with id and name = "searchid", a div tag with id ="resultid" and for example a <a href tag with id="submitid" or something else to attach a click event to. Like this:
Is it really faster? How much overhead will the umbraco-rendering of a simple page like this have?
I tried showing umbdebugshowtrace on my ajax-page of this kind. No overhead to mention at all. And the ajax-request to run a ordinary select on the db and get the results back took 35 ms according to firebug.
autocomplete
Does anyone know of an xslt autocomplete feature similar to google's homepage that searches through the nodes?
And if you don't know of one, how would you go about making one?
Something like the http://umbraco.org/documentation/books page would be groovy but I can't find anything...
Hi Chau, this functionality is actually available in Umbraco by utilizing the Ultimate Picker datatype. Take a look under Developers/Data Types in your Umbraco installation.
-- Nik
Hi Chau,
I assume it's for your website frontend and not for Umbraco Admin.
There's at least 2 good ways of doing this:
requires you to now the ways of .net coding
Also .. you could go and do a usercontrol but that seems like overkill when all you do is retrieve information.
The XSLT + jQuery way you'll need to:
1. Create an xslt file that renderes the output by traversing some umbraco nodes. Just let it return the markup fragment you need. Like <ul>...</ul>. Make the macro accept a parameter and let your code filter the nodes on this.
2. Add this macro to a template, example "ajaxsearch"
3. Create another template that should render your page. You could use the runway textpage. Add jquery reference, a input field with id and name = "searchid", a div tag with id ="resultid" and for example a <a href tag with id="submitid" or something else to attach a click event to. Like this:
<input id="searchid" name="searchid" value=""></input>
<a href="#" id="resultid">Go for it</a>
<hr/>
<div id="resultid"></div>
4. Throw in this code in the template (or move it to an external js file):
<script>
$(document).ready(function(){
var _mybutton = $('#submitid'); //
_mybutton.click(function(){
var _this = this;
var _searchid = $('#searchid').val();
var _result = $('#resultid');
$.ajax({
url: "/ajaxsearch.aspx",
data: "search="+_searchid,
success: function(msg){
_result.html(msg);
}
});
return false;
});
});
</script>
Try it :-)
/Jesper
... of couse this will only render the result below in a <ul></ul> structure but that will get you started.
/Jesper
Hey thanks Jesper. Can this be done with an ahsx page too?
Sure can, but why .-)
It's faster...
Is it really faster? How much overhead will the umbraco-rendering of a simple page like this have?
I tried showing umbdebugshowtrace on my ajax-page of this kind. No overhead to mention at all. And the ajax-request to run a ordinary select on the db and get the results back took 35 ms according to firebug.
In principle it is faster, but you are right: if you don't have any overhead the difference isn't really big.
is working on a reply...