All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

low:search:results query="..." should have a category pendant

outline4 16 Jul 2013 18:39 question, complete

hi low,
every time I want to use low search I miss the pendant to exp:low_search:results for categories.

I mean: the low_search:results mimics the channel:entries loop, but filtered.
the same thing should be possible for categories:
e.g. low_search:category_results should be the same as channel:categories, but filtered.

this makes sense, not?
is this planned somehow, somewhen?
please give us this! please!
I BEEEG YOU :D

one love
s*

I am saying this because I nest a channel:entries loop within channel:category loop and it makes it really freaking hard to use low search that way... or might you know a decent way?

Replies

  1. Low 16 Jul 2013 19:13

    The upcoming version of Low Search does contain a new feature concerning categories. If it will be the exact thing you mention here, remains to be seen.

    What is it you're trying to have as output? An example would help.

  2. outline4 17 Jul 2013 10:17

    oh shit... I thought you were going to ask for a code example.
    please: bare with me, it's not the ideal code... and it's nested like hell...
    I feel stupid, but had to do it really quickly....

    so here we go:

    main template:

     
    <section class="article_listing">
    {exp:gwcode_categories group_id="3" output_depth="1" show_empty="no" style="linear" custom_fields="yes"}
    <div class="expand-container">
    <h1 class="expander" id="cat_{cat_id}">{if category_title_{cgv_language_code}}{category_title_{cgv_language_code}}{if:else}{category_title_de}{/if}</h1>
    <div class="content level1">
    {embed="sub_sub_templates/_workshop_sub_categories" emb_cat_id="{cat_id}"}
    </div>
    </div>
    {/exp:gwcode_categories}
    </section>


    Here comes the sub_sub_templates/_workshop_sub_categories template
     
    {exp:gwcode_categories cat_id="{embed:emb_cat_id}" group_id="3" output_depth="2" offset="1" show_empty="no" style="linear" custom_fields="yes" entry_count="yes"}
    <div class="expand-container">
    <div class="margin_btm expander" id="cat_{cat_id}">
    <h2 class="dividerline">{cat_name}</h2>
    {if keyword_de}
    <p>{if keyword_{cgv_language_code}}{keyword_{cgv_language_code}}{if:else}{keyword_de}{/if}</p>
    {/if}
    </div>
    <div class="content level2">
    {embed="sub_sub_templates/_workshop_category_entries" cat_id="{cat_id}"}
    </div>
    </div>
    {/exp:gwcode_categories}


    here comes the sub_sub_templates/_workshop_category_entries template
     
    {exp:channel:entries channel="abstract" category="{embed:cat_id}" dynamic="no" disable="member_data|pagination"}
    <div class="workshop_item">
    <h3>{title}</h3>
    <div class="workshop_item_inner">
    <p>
    {embed="sub_sub_templates/_get_workshop_author_details" emb_author_id="{author_id}"}<br />
    <span class="language_{abstract_main_language}">{gv_{abstract_main_language}_{cgv_language_code}}</span><br />
    <a href="{page_uri}" class="above_all">See Details</a>
    </p>
    </div>
    {sp_edit}
    </div>
    {/exp:channel:entries}


    yee-haaa... here we go! 500 queries!

    now If I would like to filter this I would get loads of empty categories...
    or woudn't I?

  3. Low 17 Jul 2013 10:32

    Yeah, that'll get you 500 queries in no-time. How about an example of the output itself? I'm sure I could deduce it from your code, but I'd like to see your example of output (without HTML tags) of what it is you'd like to see. Something like

    - Parent cat 1
    -- Child cat 1
    --- entry 1
    --- entry 2
    -- Child cat 2
    --- entry 3

    Or something along these lines. And also mention how Low Search would come into play. I take it you're filtering entries, so the amount of categories you want to display depends on the entries that match a search query. Right?

  4. outline4 17 Jul 2013 11:34

    you are right:
    that will give exactely the output you described...

    here's the link: fice-congress2013.ch/programm/workshops/

    I would for instance like to filter by language, so only categories that have entries with the specified language are shown...
    so I would have to have a category tag that accepts the query parameter and the standard search:results tag.

    and I also have a second category that would let users filter for the type (workshop or symposium) and for all sorts of other stuff (categories and custom-fields).

    and yes: the amount of categories would depend on the entries that match the search query!

  5. outline4 17 Jul 2013 14:39

    I've updated the link with a filter...
    you'll especially see what I mean when you filter by the language "french"...
    fice-congress2013.ch/programm/workshops/eyJjb2xsZWN0aW9uIjoiYWJzdHJhY3QiLCJyZXN1bHRfcGFnZSI6InByb2dyYW1tXC93b3Jrc2hvcHMiLCJzZWFyY2hfbW9kZSI6ImFsbCIsInNlYXJjaDphYnN0cmFjdF9tYWluX2xhbmd1YWdlIjoiZnIifQ
    there's just 3 entries matching that criteria... and a whole bunch of empty categories!

    is it just me, or do others whant this functionallity as well?
    this is the third time I would like to use low search, and it's the third time that I really miss the category filter function... but maybe there's other ways to achieve what I like to achieve? maybe you can enlighten me?

    cheers
    stefan

  6. Low 17 Jul 2013 14:55

    What you describe isn't necessarily down to Low Search. Yes, people want to show entries grouped by their category; that's nothing new (see this blog post from 2010). Even the native channel:entries tag could show entries for not all categories, resulting in the same issue you describe here.

    So you need to approach things from a different angle. You're looking for entries. You're displaying entries. The fact that they're grouped in categories is less important. If you want to display only the categories that are in the current result set of the Results tag (or channel:entries tag for that matter), you first need to know which entries those are.

    I can see that you're using GWcode Categories. According to its docs, it supports the entry_id="" param, limiting the categories it puts out to the entries given. So, if you feed it the search results IDs, you've got that covered.

    You'd probably still need an embed or two to get the search results IDs etc., but I reckon Stash could also help here (although I'm not too familiar with that add-on myself).

    Low 17 Jul 2013 15:05

    Here's how to get entries per category with Stash: https://github.com/croxton/Stash/wiki...

  7. outline4 17 Jul 2013 15:11

    wow! you're a hero!

    I will definitely check that out tonight and report back!
    I knew I was on the wrong track, but was too deep into the project and deadlines to find a decent solution.

    thank you so much for your time!
    stefan

  8. outline4 18 Jul 2013 18:50

    hi low.. I've been on a long jurney to get what I need...
    and the filters still don't exactely get what I need...
    but you've surely put me on the right track!
    thanks!