Textpattern plugin with conditional tests for article list pages
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
releases
README.textile
config-dist.php
soo_if_frontpage.php

README.textile

soo_if_frontpage

This is a plugin for Textpattern.

Overview

Similar to the glx_if_frontpage tag from the no-longer-supported glx_if plugin. Most of that functionality is now available through core Txp tags, but not this (well, not without an absurd stack of conditional tags).

Usage

<txp:soo_if_frontpage>
...
<txp:else />
...
</txp:soo_if_frontpage>

soo_if_frontpage evaluates to true if the current page context is:

  • an article list, and;
  • not search results, and;
  • not a listing of articles by category, and;
  • not a listing of articles by author, and;
  • not a listing of articles by month, and;
  • not an image page, and;
  • in one of the sections listed in section (defaults to the ‘default’ section only), and
  • (optionally) a single-page list or the first page of a multi-page list, if the pg attribute is set.

Attributes

None required.

  • section (Txp section name[s])
    Comma-separated list of allowed sections. Leave empty to restrict condition to the default (i.e. home) section. Use section="*" to include all sections.
  • pg (boolean) default false
    Whether or not to check for the “pg” URL query param (e.g., http://my-site.com/?pg=2).
    Set pg="1" to allow only single-page lists or the first page of a multi-page list.

Examples

Most restrictive case

<txp:soo_if_frontpage pg="1">
... Home page ONLY
<txp:else />
... any other page
</txp:soo_if_frontpage>

The above example returns true for the home page only. E.g., http://example.com/ will cause the tag to return true, but any other standard Txp URL will return false.

Least restrictive case

<txp:soo_if_frontpage section="*">
... Home page, section front page, plus subsequent pages of a paginated list
<txp:else />
... Indivdiual article; individual image; category, author, date, or search result lists
</txp:soo_if_frontpage>

The above example returns true on the home page, any section front page, and any paginated variation thereof. E.g., these pages would all return true:

  • http://example.com/
  • http://example.com/?pg=2
  • http://example.com/news/ (where “news” is a section name)
  • http://example.com/news/?pg=7

Version History

0.1.9 (2017/02/13)

Txp 4.6 compatibility update

0.1.8 (1/14/2011)

Added check for global image context (i.e., the p query parameter)

0.1.7 (1/4/2011)

Documentation updated with descriptive examples. (Thanks to Andre D for the suggestion.)

0.1.6 (10/7/2010)

More code cleaning, after I remembered that $pretext is already extracted in global scope

0.1.5 (10/7/2010)

Documentation update, code cleaning

0.1.4 (10/6/2010)

New feature: section="*" is a shortcut for specifying all sections (including the default section)

0.1.3 (6/22/2010)

Fixed bug: section front pages now treated correctly (thanks, Victor)

0.1.2 (7/2009)

Added author and month search to the conditions to check against

0.1.1 (7/2009)

Added pg attribute; code and documentation cleaning; updated plugin template

0.1 (1/2008)

soo_if_frontpage tag with section attribute