The issue is that entries are in several categories and can be Featured (a FieldPack pill with yes/no options) but only want certain categories to show the entry.

So I have a featured_listing_category WB Category fieldtype setup.

I had this worked out but apparently still not working the way expected. I have the following code:

{if !'{exp:phpstringfun function="strpos" par1="{featured_listing_category}"}{segment_4_category_id}{/exp:phpstringfun}’}

With {featured_listing_category} outputting 399|400 and {segment_4_category_id} outputting 372

I'm trying to test whether {segment_4_category_id} is included with {featured_listing_category}.

If it helps here is my template snippet:

      {if segment_5 ==''} category="{segment_2_category_id}&{segment_4_category_id}"{/if}
      {if segment_5} category="{segment_6_category_id}&{segment_4_category_id}"{/if}
{if !'{exp:phpstringfun function="strpos" par1="{segment_4_category_id}"}{featured_listing_category}{/exp:phpstringfun}'}
    <div class="listingItem featuredListing">
      <div class="featuredIcon"></div><!-- /.featuredIcon -->
      <div class="image">
        {if main_image}
        {exp:ce_img:pair src="{main_image}" width="165" height="165" allow_scale_larger="yes" crop="yes|center|center" }<a href="/listing/details/{url_title}"><img src="{made}" width="{w}" height="{h}" alt="" /></a>{/exp:ce_img:pair}
        {if main_image ==''}
        <img src="/uploads/default_listingItemImage.jpg" alt="" />
      </div><!-- /.image -->
      <div class="content">
        <div class="buttonReviews">
          <p><a href="/listing/details/{url_title}/{segment_2}/{segment_4}" class="btn orange">View Listing</a></p>
          <div class="reviews">
            {exp:rating:stats collection="Book Reviews" entry_id="{entry_id}" precision="1"}
              {if rating_no_results}<p><a href="/listing/details/{url_title}/">Rate This Listing</a></p>{/if}
          </div><!-- /.reviews -->
        </div><!-- /.buttonReviews -->
        <h3><a href="/listing/details/{url_title}">{title}</a></h3>
        {addresses limit="3"}
        <p>{if company_name}{company_name}<br />{/if}{if address1}{address1}{/if} {address2} {if city}<br>{city}, {/if} {if state}{state}{/if} {if phone}<br>Phone: {phone}{/if} {if website_url}<br> <a href="http://{website_url}" target="_blank">{website_url}</a>{/if}</p>
        {if row_count == total_rows && total_rows > 1}
        <p><a href="/listing/details/{url_title}/">See More</a></p>
        {if overview}
      </div><!-- /.content -->
      <div class="clearfix"></div><!-- /.clearfix -->
    </div><!-- /.listingItem -->
{if "|{featured_listing_category}|" *= "|{segment_4_category_id}|"}
    {!-- Is Included --}
    {!-- Isn't Included --}

Outputs as example:

{if "|399|400|" contains "|372|"}

Pipes required either side to ensure partial cats don't get incorrectly matched, e.g. 399 contains 39.

| improve this answer | |
  • Using {if "|{featured_listing_category}|" *= "|{segment_4_category_id}|"} testing {/if} inside my exp:channel:entries gets me a Parse error: syntax error, unexpected T_STRING in error. – Mark Busnelli Jr Nov 12 '15 at 20:14
  • Same error with {if "|399|400|" *= "|400|"} testing {/if} too :\\ – Mark Busnelli Jr Nov 12 '15 at 20:22
  • Issue is with *= never used that before w/EE. Is that available w/2.7.3? – Mark Busnelli Jr Nov 12 '15 at 20:26
  • looks like =* is only a 2.9 thing :/// – Mark Busnelli Jr Nov 12 '15 at 20:49
  • upgrading EE, will let you know if that works after that! – Mark Busnelli Jr Nov 13 '15 at 1:05

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.