Sometimes you might want to test for particular directories or subdirectories on your site. This custom module snippet saves the pieces of the URL in XPHP variables that you can use when creating templates and widgets.
For instance, the page myuni.edu/academics/programs/chemistry/ would then generate the XPHP variables:
<xphp var=”url_segment_1” /> = academics
<xphp var=”url_segment_2” /> = programs
<xphp var=”url_segment_3” /> = chemistry
So, using XPHP Logic, you might want to say “only show this when we’re in a subdirectory called X.”
Or, in the example above, let’s say all your academic programs had that URL format: you could then add an image widget to your template pulling images where <arg id=”tag”><xphp var=”url_segment_3 /></arg>.
The possibilities are endless, and there’s great time-saving potential with this tool.