0

I have a section set up to display contents based on category URL information and it works great. However, when I do a search, the search result URL has a unique value in segment_4 that doesn't fit into any of the designated categories:

http://rouviere.com/photo/image/fall-colors-alpine-loop-utah9/5918ab43c62403abdef86474b6228f32

In this case I would prefer to hide the conditional content, but I am not sure how to work that segment_4 value into a conditional since it will change with each search return.

I am thinking along the lines of only display the content if segment_4 is not a number.

1

I'm not sure I understood you, but the conditional you mentioned is:

{if !(segment_4 ~ "/^\d+$/") } the `segment_4` isn't a number{/if}

I hope it helps.

2
  • 1
    Could be slightly more elegant with {if segment_4 ~ '/^\D*$/'} as \D matches any non-digit. – Low Feb 19 '15 at 21:21
  • My bad! You're right! Please, update it, @Low! – Robson Sobral Feb 20 '15 at 0:29
0

If you don't already have URL Helper ( https://devot-ee.com/add-ons/url-helper ) or Seg2Cat ( http://gotolow.com/addons/low-seg2cat/ ) installed, I'd suggest installing URL Helper (they both use the same syntax; URL Helper has a few more variables, so that's the one I'd recommend getting; both are free).

Once you've got that, you'll have access to a couple of new variables you can use for some conditionals to test whether or not segment 4 (or any other segment) is a valid category or not.

I suspect you could use something like this...

{if "{last_segment_category_id}" == ""}The last segment is not a category{/if}

... and work out a way to achieve what you're looking for.

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.