Wait a minute... This content is very very old. We no longer sell or support this theme version. New Topics
Version 9
George Sanchez
0 points
Beginner
Hi,
Just want to share the following code that helps to achieve having an automatic redirection of selected items at the search categories dropdown.
At the _functions.php file, go down around line 84. There is the select statement for the dropdown. Add the following code inside the select where it says:
Just above that select statement, copy the following javascript code:
<script language=”javascript”>
function SelectRedirect(categterm){
//change term to lowercase
categterm = categterm.toLowerCase();
//change your custom slug already in place (eg.listings.. or any other custom slug etc)
var url = ‘/listings/’;
//remove the dashes that appears at the begining for subcategories items
var before = categterm;
categterm = before.replace(/-+/g, ”)
//replace blank characters with dashes to separate multiple words with dashes (e.g. multiple-words-here
var before = categterm;
categterm = before.replace(/ +/g, ‘-‘) // notice the space character just before the +
//replace slahes characters with dashes (e.g. if you have a category slug such as Term1/Term2 will be term1-term2
var before = categterm;
categterm = before.replace(/\/+/g, ‘-‘)
//replace the first dash before terms
var before = categterm;
categterm = before.replace(/-+/, ”)
//replace blank spaces with dashes
re = /\s*\n\s*/;
categterm = categterm.split(re);
re=/(\S+)\s(\S+)/;
Hi,
Just want to share the following code that helps to achieve having an automatic redirection of selected items at the search categories dropdown.
At the _functions.php file, go down around line 84. There is the select statement for the dropdown. Add the following code inside the select where it says:
//before
<select name=”cat1″ class=”form-control input-lg”>
//after
<select id=”category” name=”cat1″ class=”form-control input-lg” onchange=”SelectRedirect(this.options[this.selectedIndex].text);”>
Just above that select statement, copy the following javascript code:
<script language=”javascript”>
function SelectRedirect(categterm){
//change term to lowercase
categterm = categterm.toLowerCase();
//change your custom slug already in place (eg.listings.. or any other custom slug etc)
var url = ‘/listings/’;
//remove the dashes that appears at the begining for subcategories items
var before = categterm;
categterm = before.replace(/-+/g, ”)
//replace blank characters with dashes to separate multiple words with dashes (e.g. multiple-words-here
var before = categterm;
categterm = before.replace(/ +/g, ‘-‘) // notice the space character just before the +
//replace slahes characters with dashes (e.g. if you have a category slug such as Term1/Term2 will be term1-term2
var before = categterm;
categterm = before.replace(/\/+/g, ‘-‘)
//replace the first dash before terms
var before = categterm;
categterm = before.replace(/-+/, ”)
//replace blank spaces with dashes
re = /\s*\n\s*/;
categterm = categterm.split(re);
re=/(\S+)\s(\S+)/;
for(var k=0;k<categterm.length;k++){
categterm[k] = categterm[k].replace(re,’$1-$2’);
}
//redirect dropdown to category and/or subcategory
window.location=url+categterm;
}
</script>
Members Only Content
This reply is for PremiumPress customers only.
Login NowMembers Only Content
This reply is for PremiumPress customers only.
Login Now