Page 1 of 2
Search passthru parameter not working
Posted: Sun Jan 19, 2014 10:26 pm
by gocreative
I'm using ListIt2 to show a list of useful links. I'm also using the Search module to search the website, however when clicking on any of the Useful Links in the search results, the item detail is displayed in the Search page template, not the page it's supposed to (a page called Useful Links which has an alias of "useful-links").
Reading the Search module help, I've come across the passthru parameter and I'm calling it as follows, without any luck:
{search resultpage="search" passthru_ListIt2UsefulLinks_detailpage='useful-links'}
No matter what module parameters I pass through, it’s still loading the search results page when it displays the details of any Useful Links items. It is using the correct detail template though (the default).
Am I doing something wrong here?
Re: Search passthru parameter not working
Posted: Thu Jan 23, 2014 10:34 am
by paulbaker
Hmmm, I can't get it to work either. Or perhaps I am trying to do something slightly different.
My ListIt2 instance is called "ListIt2GovernorTeam". I use it on a page called "governors".
When a search matches an item in ListIt2GovernorTeam, the search module links to e.g. [root]/governorteam/dawn-smith/75/default and shows the ListIt2 info using the default ListIt2 detail template.
What I actually want the search module to do when it matches an item in ListIt2GovernorTeam is just link to the page called "governors".
I use this to call the search module:
Code: Select all
{search passthru_ListIt2GovernorTeam_detailpage="governors"}
The search module seems to ignore this passthru parameter.
In my ListIt2 instance options I have Module defaults set - both Detail page and Summary page are set to the "governors" page.
Perhaps we're both misunderstanding something?
[steds]
Re: Search passthru parameter not working
Posted: Thu Jan 23, 2014 3:01 pm
by JohnnyB
gocreative, paulbaker,
I think you still need to modify the search results template so it can handle the request properly.
In your template, you'll need to grab results belonging to the module:
For example,
Code: Select all
{if $entry->module == 'ListIt2YourInstance'}
... then do stuff for it
{/if}
Also, you may need to capture the ListIt2YourInstance template being wanted for search results.
For example, a blog's custom search result page:
Code: Select all
{capture assign="results"}{CGBlog action=detail articleid=$entry->modulerecord detailpage="blog-articles" detailtemplate=''search_template''}{/capture}
One more detail.... In older versions of CMSMS 1.8, 1.9, I had to do regex to change the URL to the article because Search will still try to send it to your default search results page. I don't know if this is the case still.
But, you might need something like
{$articleURL|regex_replace:"/18/":"22"}
Where $articleURL is a var set for the full article link inside of the CGBlog detail template, 18 is the search results page id, and 22 is the desired page id.
Re: Search passthru parameter not working
Posted: Thu Jan 23, 2014 4:06 pm
by calguy1000
This is not an issue with the search module. but with the Listit2 module (or other module).
Search, when it finds a result for a module, calls the module so that the module can generate the URL, retrieve and format a title etc.
If the module is not using the passed in parameters, then it's the module's fault.
Re: Search passthru parameter not working
Posted: Thu Jan 23, 2014 9:24 pm
by gocreative
Thanks everyone for the input. That being the case, will JohnnyB's workaround do the trick, or is there something else that can be done?
Re: Search passthru parameter not working
Posted: Thu Jan 23, 2014 9:54 pm
by JohnnyB
Try setting this into the template and see if there is an entry for the Listit2 instance for module or modulerecord
<pre>{$entry|@print_r}</pre>
Re: Search passthru parameter not working
Posted: Thu Jan 23, 2014 10:28 pm
by gocreative
Into the search results template, you mean?
Re: Search passthru parameter not working
Posted: Thu Jan 23, 2014 11:17 pm
by JohnnyB
gocreative wrote:Into the search results template, you mean?
yep. That way if the module is passing what is needed, as per Calguy, they it should show up with a print_r
Re: Search passthru parameter not working
Posted: Fri Jan 24, 2014 6:51 am
by gocreative
JohnnyB wrote:Try setting this into the template and see if there is an entry for the Listit2 instance for module or modulerecord
<pre>{$entry|@print_r}</pre>
There's this:
Code: Select all
[url] => http://mysite.com/item-alias/29
[urltxt] => Item Title
[title] => Module Friendly Name
[intweight] => 3
[module] => ListIt2ModuleName
[modulerecord] => 24
[weight] => 100
Obviously I've replaced some of the above, but hopefully this gives you what you need to know.
Re: Search passthru parameter not working
Posted: Fri Jan 24, 2014 2:25 pm
by velden
In your case a UseFulLink item actually has a detail view?
Or do you just want the search result link point to the page with all the links.
Re: Search passthru parameter not working
Posted: Fri Jan 24, 2014 3:11 pm
by velden
Intrigued by this question I've been testing some things.
This seems to work in my test environment.
NOTE: Needs CGSimpleSmarty module!
Code: Select all
{if $entry->module == 'ListIt2UsefulLinks'}
<li>{$entry->title} - <a href="{module_action_link page='useful-links' urlonly=1 module='ListIt2UsefulLinks' action='detail' item=$entry->modulerecord}
">{$entry->urltxt}</a> ({$entry->weight}%)</li>
{/if}
I started with a more complicated approach to get the ALIAS of the item which is needed for the 'item' parameter of LI2. Although the help explicitly states it must be alias I tested it later with the item ID which seems to work... That makes it a lot easier because item id is already available in the search entry.
Re: Search passthru parameter not working
Posted: Sun Jan 26, 2014 1:10 am
by gocreative
Thanks velden! I had completely forgotten about {module_action_link}. This code helped solve my problem for a range of modules, so I really appreciate your help on this

Re: Search passthru parameter not working
Posted: Tue Feb 18, 2014 2:03 am
by Cerulean
The {module_action_link} method works but doesn't give you a pretty URL in the link.
Another option is to create a ListIt2 summary template to use in the site search results, e.g.
Code: Select all
{foreach from=$items item=item}
<a href="{$item->url}">{$item->title|cms_escape}</a>
{/foreach}
And then in your search template:
Code: Select all
{if $entry->module == "ListIt2MyInstance"}
<li>{$entry->title} - {ListIt2MyInstance summarytemplate="sitesearch" include_items=$entry->modulerecord} ({$entry->weight}%)</li>
{/if}
Re: Search passthru parameter not working
Posted: Tue Feb 18, 2014 5:06 am
by Stikki
You guise are nuts, seriously. Nuts.
Re: Search passthru parameter not working
Posted: Tue Feb 18, 2014 5:19 am
by gocreative
Nuts? Maybe. Solving problems for ourselves and others? Definitely!