[-- SEARCHRESULT --] syntax and possible customization?

General ShopSite user discussion

[-- SEARCHRESULT --] syntax and possible customization?

Postby flicman » Mon Jun 16, 2008 10:23 am

Hey there!

I'm working with our search results page at the moment, and I'd like to edit the syntax for the [-- SEARCHRESULT --] variable. At the moment, on a bare page, putting this code in the search template
Code: Select all
[-- LOOP SEARCH --]
  [-- SEARCHRESULT --]
[-- END_LOOP SEARCH--]
yields this result:
searchresult wrote:PRODUCT DESCRIPTION
LINK1
LINK2
LINK3
where LINK# is the Product On Pages result.

Because of the way I use product layouts, I'd rather have a search layout where I could column-ize the results, or even list the page links atop the product so maybe you'd see:
searchresult wrote:On Pages LINK1, LINK2 were found:
PRODUCT DESCRIPTION
or something.

So, the question becomes, can I edit the syntax of the variable itself?

Thanks for reading through this post and for any help y'all might have.
flicman
 
Posts: 24
Joined: Mon Jun 16, 2008 9:02 am
Location: Hollywood, CA

Postby Jim » Mon Jun 16, 2008 10:56 am

There is no way to change the output of the [-- SEARCHRESULT --] tag. The elements of the tag will always be listed with the product first and the associated links next. So you can check its content and do some formatting depending on whether it is a product or the links for that product.

So you can expand your code to separate the items out by using something like
Code: Select all
[-- LOOP SEARCH --]
  [-- IF SEARCHPRODUCT --]
start your formatting for the product layout here
     [-- SEARCHRESULT --]
end your formatting for the product layout here
  [-- ELSE --]
start your formatting for links here
     [-- SEARCHRESULT --]
end your formatting for links here
[-- END_LOOP SEARCH--]
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby flicman » Mon Jun 16, 2008 12:42 pm

Thanks, Jim!

Through some trial and error (my old standby!) I'm currently using this:
Code: Select all
[-- LOOP SEARCH --]
  [-- SEARCHRESULT --]
  [-- IF SEARCHLINK --]
 <br>
  [-- ELSE --]
      Product Found On The Following Pages:
  [-- END_IF --]
[-- END_LOOP SEARCH--]

I don't really understand how the search is returning results. If it was simply posting the Product On Pages links from products that match the search query, it seems like there'd be a way to organize that output. Instead, the simplest results page I can come up with is
Code: Select all
&nbsp;<BR>LINK


At the bare minimum, I'd like to put a box around the product and the pages on which this product can be found. We use a blue line beneath the Add to Cart button, and it makes things doubly confusing to have the pages beneath that. Some of this can obviously be fixed by text formatting, but I really need to box the related results.

Thanks again for your help.
flicman
 
Posts: 24
Joined: Mon Jun 16, 2008 9:02 am
Location: Hollywood, CA

Postby Jim » Mon Jun 16, 2008 3:56 pm

The way the results are returned for all products that match a search term is like this:
Product 1
Link to page product 1 found on
Link to page product 1 found on
. . .
Product 2
Line to page product 2 found on
Link to page product 2 found on
...
Product 3
Link to page product 3 found on
Link to page product 3 found on
...
etc.

When you go into the
[-- LOOP SEARCH -- ] section of the template it will step through all the
products that match the search term using the above syntax, (Product- Associated links ) So it will output the first product with its links then the second product with its links etc.
The layout of the product itself is defined by the template assigned under Preferences > Search Settings > Search Layout >Product Template Override: so it can either be the normal product template an override template. If you want a box around your product you could put that in the search template or define it in the [-- LOOP SEARCH -- ] and do it in the section I indicated earlier
Code: Select all
[-- IF SEARCHPRODUCT --]
start your formatting for the product layout here
     [-- SEARCHRESULT --]
end your formatting for the product layout here
  [-- ELSE --]

The format for the link is defined in the template set in Preferences > Search Settings > Search Layout >Link Template Override:

So a way of including everything in a box would be to setup a table before the LoopSearch section and end it after the [-- end_loop search --] YOu could then make a table row and table cell for each product and associated links that are found. I believe there have been other posts that show how to do a multi column search result. You could also look at some of the Shopsite provided templates that allow for multi column search results for code on how this is done.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby flicman » Mon Jun 16, 2008 10:37 pm

This got me thinking in the right direction. Basically, I open a table above the search term, then, a few lines later, use this code:
Code: Select all
[-- LOOP SEARCH --]
[-- IF SEARCHPRODUCT --]
</td></tr>
</table>
<p>&nbsp;</p>
<table width="750" border="1" cellpadding="1" cellspacing="4">
<tr><td>
  [-- SEARCHRESULT --]
</td></tr>
<tr><td>
[-- END_IF --]
[-- IF SEARCHLINK --]
<br>
 [-- ELSE --]
   Product Found On The Following Pages:
[-- END_IF --]
[-- END_LOOP SEARCH --]

It allows me to properly wrap the product with its pages with some space in between. Thanks for all your help. Now I'm off to write CSS so the spacing doesn't look so janky.
flicman
 
Posts: 24
Joined: Mon Jun 16, 2008 9:02 am
Location: Hollywood, CA


Return to User Forum

Who is online

Users browsing this forum: No registered users and 39 guests