Testing for multiple ticked categories

  • I have two categories in a category set. The following tests if one or the other is ticked. Fine.



    However I'd like to test if both categories are ticked and output...


    TO LET (may sell)


    Can this be done using perch:categories and perch:if ?

  • davedesigner

    Changed the title of the thread from “Testing for multiple values on ticked categories” to “Testing for multiple ticked categories”.
  • drewm

    Approved the thread.
  • That <perch:else> isn’t actually doing anything above - it needs to be nested within a control structure to work.


    I’m not sure there’s an obvious way to perform category intersection from within a template. You possibly might be able to do it with a template filter, as the filter should be given access to other items in the same templated set. That would enable you to inspect both values and output accordingly. However, that’s theory - you’d need to try it to be sure.

  • Hello davedesigner


    Assuming your category set sale has only 2 categories, you can check for the total number of selected categories: if you have 2 categories, you know both for-sale and for-rent are selected:



    Note this is a workaround. It checks for how many categories selected, not whether the selected categories are forfor-sale and for-rent. If you have more categories in this set, this approach wouldn't be suitable.

  • Ah! max="1" Never knew that. Perfect. :)


    I could now use a override list with all the alternatives the client needs to display...


    Code
    1. <perch:content id="status" type="select" label="Status" type="radio" options="-,To Let (May Sell),Under Offer,Sold,Now Let" searchable="false" suppress="true" help="Override the badge status shown on property - Hidden will hide this property in the list" />