0

i have been pulling my hair out trying to understand this so any help is appreciated.

I have a channel 'Content' which is just the 'pages' of the site. My template groups are setup using only the 'index' template: template_group/template

eg,
coaching/index
management/index

And my navigation (done using Navee): template_group/entry1 (from 'Content' channel)

coaching/schools
coaching/instructors
management/forms

All straight forward. Now i have a simple search form which i want people to be able to search the entries on the site (from the 'Content' channel) but i need to know how to produce the correct search results page.

In channel preferences > path settings > channel URL ... ..my 'Content' channel does not have a specific url - since it is different depending on the template group.

eg, If i enter and save http://www.example.com/coaching/ into the field, then do a search for 'schools', the results display http://www.example.com/coaching/schools which is correct. But if i search 'forms' the results brings up http://www.example.com/coaching/forms instead of http://www.example.com/management/forms

So since the 'Content' channel does not have a specific 'Channel URL', how do i get search results to product the link to the correct page/entry??




UPDATE. My Solution.
I created categories for each of the six template groups, then assigned each page/entry to a category. I then used the below conditionals to produce the correct search results:

{if category_url_title == "ONE"}
<h3><a href="/ONE/{url_title}">{title}</a></h3>{/if}

{if category_url_title == "TWO"}
<h3><a href="/TWO/{url_title}">{title}</a></h3>{/if}

{if category_url_title == "THREE"}
<h3><a href="/THREE/{url_title}">{title}</a></h3>{/if}

etc, etc..

Ps. Using the above with {excerpt} just duplicated the excerpt from the first result, to each other result. So instead of excerpt i used a custom field (meta description text field).

1

ZEDG: if I'm understanding your setup correctly, each entry in your 'Content' channel equates to a specific page on the site, right? So each 'page' has its own entry_id. Thus, you could run a conditional to examine on the entry_id of each result, and provide specific template code for each possibility. (Switchee would be a better option for this task than native if/else conditionals, as it would only parse the template code for the matching entry_id, rather than parsing the code for every possible entry_id and then discarding the non-matches).

| improve this answer | |
  • Thanks for that. Unfortunately there are too many entries overall to make that feasible (if i understand your meaning). .. I have instead run a conditional based on what category each 'page'/entry belongs to (being one of the template groups). – ZEDG Mar 17 '15 at 12:55
0

A workaround would be to assign each channel a category and then base the url slugs on that in the search result output.

| improve this answer | |
  • Do you mean assign a category to each template group? There is only the one main channel 'Content'. – ZEDG Dec 11 '14 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.