I have some code inside a global snippet that I only want to display on a blog listing page. So the allowed URL types could be:
- /blog
- /blog/P10
- /blog/category/crackers
- /blog/author/skeletor
I do not want the code to display on the individual blog post pages (/blog/my-post-title).
So the pseudo-conditional would be:
If
segment_1
equals "blog" ANDsegment_2
is empty- OR
segment_2
is pagination - OR
segment_2
equals "category" - OR
segment_2
equals "author"
The pagination is the part that's tripping me up. I know I can use Switchee to use regexes, but it doesn't let me use advanced AND/OR and () operators to string cases together. Something like:
{if segment_1 == 'blog' AND (segment_2 == '#^P(\\d+)$#' OR segment_2 == 'category' OR segment_2 == 'author' OR segment_2 == '')}
Is there an add-on that will let me use regexes inside advanced conditionals, or is there another way of doing it altogether?
segment_2
conditionals together. So it would be something like{if segment_1 == 'blog' AND (segment_2 == '#^P(\\d+)$#' OR segment_2 == 'category' OR segment_2 == 'author' OR segment_2 == '')}