0

What I'm hoping to achieve is for someone visiting /events on my site to be redirected to the current event's page ( /events/{url_title} ). However, this redirect would be dynamic to check for the one entry I have marked as the current entry, via a custom current_entry field I've created (only one entry would be marked as true for this).

Is this possible to achieve without leveraging a plugin? I've only managed to get as far as hardcoding the redirect...

    {if last_segment == 'grid'}

        {redirect='events/grid/sxsw'}

    {if:else}

1 Answer 1

0

You could perhaps leverage the search param on a channel entries tag.

https://docs.expressionengine.com/latest/channel/channel_entries.html#search-field-name

Possible Example:

{if last_segment == 'grid'}

    {exp:channel:entries
        channel="events"
        limit="1"
        search:current_entry="Yes"}

        {redirect='events/grid/{url_title}'}

    {/exp:channel:entries}

{if:else}

    ... whatever else you were planning

{/if}

This would depend on your current_entry field having a value of "Yes" for the entry you want to feature. There is, however, an easier way to go about this that wouldn't require your custom field. Provided that you only have one featured entry at a time, you can tag that entry as "Sticky". It's under the Options tab on a channel entry form ("Make Entry Sticky"). Then do the same thing but drop needing a custom field. A sticky entry should always come up first in a channel entries loop.

{exp:channel:entries
    channel="events"
    limit="1"}

    {redirect='events/grid/{url_title}'}

{/exp:channel:entries}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.