ExpressionEngine addons

Any segment

Description

A plugin that can be used with ExpressionEngine conditionals which returns TRUE if a specified string is found in any segment. Does this happen to you?

  • Your templates are accessible on your site with or without the default template group.
    eg.
    yoursite.com/index.php/en/blog
    yoursite.com/index.php/blog

    ... but you have conditionals in your template targeting specific segments.
    eg. {if segment_2 == "blog"}

    What happens if en is not part of the URL? blog may not be in segment_2

In this case, the any_segment plugin would look at all segments and return true if any segment contains "blog".

Usage

{ exp:any_segment equals="projects"}

Parameters

equals="projects"

The plugin returns TRUE if the equals parameter is found in any segment of the URL.

Example use

{if {exp:any_segment equals="projects"}} ... Show content {/if}

Installation

Copy pi.any_segment.php to your system/plugins folder

Changelog

0.1

  • First version
  • Works with simple conditional {if}, {if:elseif}, {if:else} tags
Creative Commons License