ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How can I use the channel listing index template for my search results?

June 26, 2012 7:24am

Subscribe [2]
  • #1 / Jun 26, 2012 7:24am

    amityweb

    162 posts

    Hi

    I have a blog channel, in it the index.html file which lists the blogs, and is also used to show the single entry.

    I want to add search. But I cannot find anywhere that allows me to use the same template. I do not see why i should create another template with the same code in it, to display a filter of results from the blog. Its all the same, apart from the search results is filtered.

    So is there a way to use the same template, cant find anything online.

    Thanks

  • #2 / Jun 27, 2012 11:43am

    Shane Eckert

    7174 posts

    Hello amityweb,

    Thank you for posting your question here on the ExpressionEngine forums.

    I think the reason behind why you cannot find an example of what you have listed is that the search results are listed by it’s own tag pair. That lends itself to being it’s own template.__Have you tried making the results page the same template and using something like [url=http://devot-ee.com/add-ons/switchee]Switchee to help build some cases? I have not ever tried this, but it may work just by using variables or segments.

    If you would like I can move this to the Community Help Forum to see if the community has some ideas.

    I hope this helps.

    Cheers,

  • #3 / Jun 27, 2012 12:34pm

    amityweb

    162 posts

    Ok thanks Shane. Knew about their own tags, which as you say lends itself to another template, but I was hoping someone knew a way to use the same template…

    So what I think I will do is just use an embed for the central layout part… so have two templates, but both use an embed to use the common HTML. Its not perfect because both templates have other common HTML code, not just between the tag pair, and I just hate repetition!

    On the other hand, I will also give switchee a go because we use PHP at the moment to detect pagination, and I can see their example has a pagination detection, so it may have other uses for us.

    Yes feel free to move if you want, if you and the others dont think its possible otherwise.

    Thanks a lot

  • #4 / Jun 27, 2012 12:37pm

    amityweb

    162 posts

    Oh one point to note… in the search results page URL is a bunch of random characters, in segment_2. So I did also wonder if that can be tapped into at all… so I could somehow detect it is a search results URL and then IF we can get the search phrase from that I can add the search to my regular channel entry. So if this is possible then that should work. So no need to have a search results template.

    In fact maybe I dont need to use EE search function at all, and just have a regular form that submits to listing page, and tap into the POST vars and add them to the channel entry search to filter them. Although I suspect that will break my pagination!

    Thanks

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases