diff options
author | Thomas Lange <code@nerdmind.de> | 2017-04-27 12:25:33 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2017-04-27 12:25:33 +0200 |
commit | a05ec4c805c5f0334855d171e988466858d3835d (patch) | |
tree | 1b9cb4f0855ee87c2efb8545c8fea56df1ed890a | |
parent | 76cb23030ea36f91d858f2af61ebe2e2670e200e (diff) | |
download | wiki-a05ec4c805c5f0334855d171e988466858d3835d.tar.gz wiki-a05ec4c805c5f0334855d171e988466858d3835d.tar.xz wiki-a05ec4c805c5f0334855d171e988466858d3835d.zip |
Wiki updated for version 2.0 of the blogging application.
-rw-r--r-- | Arguments.md | 25 | ||||
-rw-r--r-- | Templates.md | 6 |
2 files changed, 31 insertions, 0 deletions
diff --git a/Arguments.md b/Arguments.md new file mode 100644 index 0000000..da26303 --- /dev/null +++ b/Arguments.md @@ -0,0 +1,25 @@ +This document explains how to use the optional field for arguments in the content editor. This field can contain a list of arguments as key or key/value pairs formatted as follows: `FOO=value|BAR=value` (or `FOO=value|BAR`; `BAR` will be automatically set to `TRUE`). + +## How to access arguments in a template +Lets assume that your argument string for a specific post is something like this: `HIGHLIGHT|PREVIEW_IMG=foobar.png`. You can now access the entire (unparsed) argument string in templates by `$POST['ATTR']['ARGV']` (see template documentation for further information). This contains the unparsed argument string as he was written in the content editor. You also can access an parsed version of the arguments as key->value array with `$POST['ARGV']`: + +### Unparsed: `$POST['ATTR']['ARGV']`: + string(32) "HIGHLIGHT|PREVIEW_IMG=foobar.png" + +### Parsed: `$POST['ARGV']` + array(2) { + ["HIGHLIGHT"]=> + bool(true) + ["PREVIEW_IMG"]=> + string(10) "foobar.png" + } + +## How this arguments can be used to do something special +If you are a template developer, you can check in your templates if the argument `HIGHLIGHT` is present (arguments with no explicit value will be automatically set to `TRUE`). If true, you can highlight this post differently (if you have some "promo posts" or something: just check if this value is set and add an extra CSS class to your HTML markup which then will highlight your post). You even can add an preview image functionality. What if you want to show an preview image for each post in the list? There is no core functionality to do this, but with the argument functionality you can do this very simple: + + <?php if(isset($POST['ARGV']['PREVIEW_IMG'])): ?> + <img class="preview-img" href="<?=Application::getFileURL("images/preview/{$POST['ARGV']['PREVIEW_IMG']}")?>" alt="" /> + <?php endif; ?> + +## Conclusion +The use cases of the arguments are practically unlimited. Please note that the `standard` template does not use any arguments provided in the argument field. It is up to you whether you implement this in your own template to do something special or not!
\ No newline at end of file diff --git a/Templates.md b/Templates.md index d081abc..937d786 100644 --- a/Templates.md +++ b/Templates.md @@ -189,6 +189,7 @@ Default template for error page 404 Not Found. * `$PAGE['ID']`: Contains the unique ID of the page * `$PAGE['URL']`: Contains the complete URL to the page content * `$PAGE['GUID']`: Contains a pseudo-guid of the page +* `$PAGE['ARGV']`: Contains the arguments parsed as key->value array * `$PAGE['FILE']['LIST']`: List of extracted image URLs from the body * `$PAGE['BODY']['TEXT']`: Pre-parsed content of the page body * `$PAGE['BODY']['HTML']`: HTML parsed content of the page body @@ -196,6 +197,7 @@ Default template for error page 404 Not Found. * `$PAGE['ATTR']['SLUG']`**{!}**: Raw attribute data from database column `slug` * `$PAGE['ATTR']['NAME']`**{!}**: Raw attribute data from database column `name` * `$PAGE['ATTR']['BODY']`**{!}**: Raw attribute data from database column `body` +* `$PAGE['ATTR']['ARGV']`: Raw attribute data from database column `argv` * `$PAGE['ATTR']['TIME_INSERT']`: Raw attribute data from database column `time_insert` * `$PAGE['ATTR']['TIME_UPDATE']`: Raw attribute data from database column `time_update` @@ -203,6 +205,7 @@ Default template for error page 404 Not Found. * `$POST['ID']`: Contains the unique ID of the post * `$POST['URL']`: Contains the complete URL to the post content * `$POST['GUID']`: Contains a pseudo-guid of the post +* `$POST['ARGV']`: Contains the arguments parsed as key->value array * `$POST['FILE']['LIST']`: List of extracted image URLs from the body" * `$POST['BODY']['TEXT']`: Pre-parsed content of the post body * `$POST['BODY']['HTML']`: HTML parsed content of the post body @@ -210,6 +213,7 @@ Default template for error page 404 Not Found. * `$POST['ATTR']['SLUG']`**{!}**: Raw attribute data from database column `slug` * `$POST['ATTR']['NAME']`**{!}**: Raw attribute data from database column `name` * `$POST['ATTR']['BODY']`**{!}**: Raw attribute data from database column `body` +* `$POST['ATTR']['ARGV']`: Raw attribute data from database column `argv` * `$POST['ATTR']['TIME_INSERT']`: Raw attribute data from database column `time_insert` * `$POST['ATTR']['TIME_UPDATE']`: Raw attribute data from database column `time_update` @@ -217,11 +221,13 @@ Default template for error page 404 Not Found. * `$USER['ID']`: Contains the unique ID of the user * `$USER['URL']`: Contains the complete URL to the user * `$USER['GUID']`: Contains a pseudo-guid of the user content +* `$USER['ARGV']`: Contains the arguments parsed as key->value array * `$USER['FILE']['LIST']`: List of extracted image URLs from the body * `$USER['BODY']['TEXT']`: Pre-parsed content of the user body * `$USER['BODY']['HTML']`: HTML parsed content of the user body * `$USER['ATTR']['SLUG']`**{!}**: Raw attribute data from database column `slug` * `$USER['ATTR']['BODY']`**{!}**: Raw attribute data from database column `body` +* `$USER['ATTR']['ARGV']`: Raw attribute data from database column `argv` * `$USER['ATTR']['USERNAME']`**{!}**: Raw attribute data from database column `username` * `$USER['ATTR']['FULLNAME']`**{!}**: Raw attribute data from database column `fullname` * `$USER['ATTR']['MAILADDR']`**{!}**: Raw attribute data from database column `mailaddr` |