0

I have some code that creates my breadcrumbs and it uses this conditional:

{if segment_1 == "media" && segment_2 != "media-view" && segment_2 != ""}
<li class="breadcrumb"><p><a href="{site_url}index.php/media">Media</a></p></li>
<li class="breadcrumb"><p>{title}</p></li>
{/if}

The problem is that now there are enough media files to have multiple pages, and the pagination becomes segment_2, so it's no longer blank. So now the page is broken because its trying to put in a bunch of junk for the breadcrumbs.

How do you match against pagination? Is there a wildcard character so I could say something like the following?

{if segment_2 == "P%"}

It's been a while since I used EE and I can't seem to find the answer. thanks in advance for your help.

1

One solution would be to use MoVariables : http://devot-ee.com/add-ons/mo-variables

You can check a conditional against pagination.

There is probably a better way to do this, but this should work.

| improve this answer | |
1

The default EECMS conditionals can't check against RegEx, so your simplest solution is to use Switchee.

{exp:switchee variable="{segment_1}/{segment_2}" parse="inward"}

    {case value="#^media/P\d+$#|media/media-view|media/"}
        {!-- for this case, we show nothing --}
    {/case}

    {case value="media/{segment_2}"}
        <li class="breadcrumb"><p><a href="{site_url}index.php/media">Media</a></p></li>
        <li class="breadcrumb"><p>{title}</p></li>
    {/case}
{/exp:switchee}

To avoid complex and hard to debug RegEx, I created one first case to exclude all three situations you need to, separated by |:

  • segment_1 == media and segment_2 as pagination: ^media/P\d+$, where# delimits a RegEx;
  • segment_1 == media and segment_2 == 'media-view': media/media-view;
  • segment_1 == media and segment_2 empty: media/.

If the first case doesn't match, then the second will be tested.

| improve this answer | |

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.