diff options
author | Kevin Chabowski <kevin@kch42.de> | 2012-06-01 11:35:13 +0200 |
---|---|---|
committer | Kevin Chabowski <kevin@kch42.de> | 2012-06-01 11:35:13 +0200 |
commit | 56196c68fdbef92c6d24f100e52530e07ac01822 (patch) | |
tree | 97eafb32d862a452279d24d9125923f8c341e374 /ratatoeskr | |
parent | 71e6e63f2712d2075eca7fff5a45c73f1cfa383f (diff) | |
download | ratatoeskr-cms-56196c68fdbef92c6d24f100e52530e07ac01822.tar.gz ratatoeskr-cms-56196c68fdbef92c6d24f100e52530e07ac01822.tar.bz2 ratatoeskr-cms-56196c68fdbef92c6d24f100e52530e07ac01822.zip |
Implemented on_* tags. UNTESTED!
on_article / on_tag / on_section will execute and return its content, if
currently a(n) article / tag / section is requested.
Diffstat (limited to 'ratatoeskr')
-rw-r--r-- | ratatoeskr/frontend.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ratatoeskr/frontend.php b/ratatoeskr/frontend.php index 038485a..13fd14a 100644 --- a/ratatoeskr/frontend.php +++ b/ratatoeskr/frontend.php @@ -654,6 +654,55 @@ $ste->register_tag("title", function($ste, $params, $sub) return "<title>$pagetitle</title>"; }); +function make_on_anything_tag($field) +{ + return function($ste, $params, $sub) use ($field) + { + if($ste->evalbool($ste->vars["current"][$field])) + { + if(!empty($params["var"])) + $ste->set_var_by_name($params["var"], $ste->vars["current"][$field]); + return $sub($ste); + } + }; +} + +/* + * STETag: on_article + * Execute tag content, if currently an article is requested. + * + * Parameters: + * var - (optional) If set, the article will be stored in the variable with that name (see <article_transform_ste> for sub-fields). + * + * Returns: + * The executed tag content, if an article was requested. + */ +$ste->register_tag("on_article", make_on_anything_tag("article")); + +/* + * STETag: on_tag + * Execute tag content, if currently a tag is requested. + * + * Parameters: + * var - (optional) If set, the tag will be stored in the variable with that name (see <tag_transform_ste> for sub-fields). + * + * Returns: + * The executed tag content, if a tag was requested. + */ +$ste->register_tag("on_tag", make_on_anything_tag("tag")); + +/* + * STETag: on_section + * Execute tag content, if currently a section is requested. + * + * Parameters: + * var - (optional) If set, the section will be stored in the variable with that name (see <section_transform_ste> for sub-fields). + * + * Returns: + * The executed tag content, if a section was requested. + */ +$ste->register_tag("on_section", make_on_anything_tag("section")); + /* * STEVar: $current * Holds information about the current page in the frontend (the part of the webpage, the visitor sees). |