Page 1 of 1
[SOLVED] Search module and Products pretty URLs
Posted: Mon Jul 06, 2009 2:33 pm
by geeves
Hey guys.
I am trying to get the search module to produce Pretty URLs instead of this (index.php?mact=Products,cntnt01,details,0&cntnt01productid=27&cntnt01returnid=17) for the products module. Has anyone done this before, and if so, how.
Also, how can I include hierarchy/category names in the search?
Thanks in advance.
Re: Search module and Products pretty URLs
Posted: Tue Jul 07, 2009 5:40 am
by geeves
Hey guys.
Thought I would share what I found out. I should always remember never to be too quick and skim over module documentation.
The search tag which gives SEF results url is as follows: (in my case, searching the products module)
Code: Select all
{search modules='Products' searchtext='Search' submit='go' resultpage='page-alias' search_method='post'}
Then, I modified the search results template as follows:
Code: Select all
<h3>{$searchresultsfor} "{$phrase}"</h3>
{if $itemcount > 0}
<ul>
{foreach from=$results item=entry}
<li><a href="{root_url}/products/{$entry->modulerecord}/17/{$entry->urltxt}">{$entry->urltxt}</a> - {get_product_desc productid=$entry->modulerecord} ({$entry->weight}%)</li>
{/foreach}
</ul>
{else}
<p><strong>{$noresultsfound}</strong></p>
{/if}
In my case, I had to use a code for the product name (because that was the only unique information in my client's product catalogue. So I had to write a UDT to retrieve the product description from its ID.
Hope this helps someone else. As always, improvements or suggestions are always welcome.
Cheers
Re: [SOLVED] Search module and Products pretty URLs
Posted: Mon Jul 13, 2009 1:52 pm
by sudestmanceau
Hi,
For me, the simply {search} tag does not work with Products : always no results !
Any idea please ?
THX
Re: [SOLVED] Search module and Products pretty URLs
Posted: Mon Jul 13, 2009 2:32 pm
by geeves
How are you using the search tag? Please post it here so we can see what is wrong with it.
Re: [SOLVED] Search module and Products pretty URLs
Posted: Mon Jul 13, 2009 3:02 pm
by sudestmanceau
yes i'm just using the tag : {search} in my page.
All the others pages and news appear in the results, but never elements of Products.
Re: [SOLVED] Search module and Products pretty URLs
Posted: Mon Jul 13, 2009 3:20 pm
by Jean le Chauve
@Geeves : with {search modules='Products'} have you some results out of the module Products (ie : content, news... ) ?
Re: [SOLVED] Search module and Products pretty URLs
Posted: Tue Jul 14, 2009 1:38 am
by geeves
Here are some results from the site I am currently working on (see attached image) using the code posted above.
I am still looking for a solution to my problem about no search results for custom attributes/fields or product hierarchy posted here:
http://forum.cmsmadesimple.org/index.php/topic,35391.0.html