0

I want a checkbox called members and when a lodging is searched for, I want members to display first and the rest to be alphabetized underneath. I know I can do this via the sticky function, but the wording of it is confusing to the client. Is there a plugin that will let me rename it or a method to do what I want to do?

Currently, using low search, if I order it ascending, which i need for alphabetization, my members are added to the bottom of the list, but if I go descending then everything is reverse alphabetized.

{exp:low_search:results 
    query="{segment_3}"
    limit="10"
    paginate="bottom"
    dynamic="no"
    orderby="lodging_swita_member|title"
    sort="asc"
}

2 Answers 2

1

This is a good reason to separate your data fetching from your data output using Stash. The parse order can get tricky, but this should work... It uses the P&T checkbox-group fieldtype to tick an entry as being a 'member':

{!--  ============================================
STASH INTO A SINGLE LIST
================================================== --}

{exp:stash:set_list
    name="results"
    parse_tags="yes"
    parse_conditionals="yes"
}
    {exp:low_search:results 
        query="{segment_3}"
        limit="10"
        paginate="bottom"
        dynamic="no"
        orderby="title"
        sort="asc"
    }           
        {if {cf_options:selected option="is-member"}}
            {stash:is-member}yep{/stash:is-member}
        {if:else}
            {stash:is-member}nope{/stash:is-member}
        {/if}
        {stash:the-title}{title}{/stash:the-title}
        {stash:the-url}{permalink}{/stash:the-url}
        {stash:the-summary}{cf_summary}{/stash:the-summary}
    {/exp:low_search:results}
{/exp:stash:set_list}

{!--  ============================================
START OUTPUT
================================================== --}

<ol>
{exp:stash:get_list name="results" match="#^yep$#" against="is-member"}             
    <li>
        <a href="{the-url}">
            <h3>{the-title}</h3>
            <p>{the-summary}</p>
        </a>
    </li>               
{/exp:stash:get_list}

{exp:stash:get_list name="results" match="#^nope$#" against="is-member"}                
    <li>
        <a href="{the-url}">
            <h3>{the-title}</h3>
            <p>{the-summary}</p>
        </a>
    </li>               
{/exp:stash:get_list}
</ol>

If you want to make it DRY-er you could use a snippet for the markup inside the two get_list sections.

1

I agree - sticky is a pain. Yes, you can do it that way with a distinct custom field, though that's not how I would recommend approaching it - because without an add-on like Zenbu, you wouldn't be able to see that custom field from the main list edit screen - one of the few advantages of the sticky field is that it is present on the main list edit screen. But so is status. As of version 2.5.4, status is available for use in orderby. And while the label of "status" isn't ideal, since you can create a custom status of "member" and use status in your orderby param, maintaining your ability to group your members together at the top of the list, and still have alphabetization within each grouping.

Hope that helps.

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.