Textformatter which is inspired by the TextformatterHannaCode module.
Allows you to add tags (“Funky Functions”) to your text fields which will be replaced by markup. The markup will be generated from script files either from a configurable path below site/
or from the site/templates/fields/
folder. In contrast to TextformatterHannaCode it does not come with a backend code editor interface. All scripts must be available as files in the mentioned paths.
Other characteristic are:
- That it allows to directly pull data from fields on the same page
- It allows to select items from array-like data by given ranges and/or indexes:
images=1,3,6-9,12
- It allows to select items from WireData derived data by given selector:
images="description*=nice"
- It allows to pull data from another page field into a tag attribute:
[[nice-script field="selector"]]
- It will render available scripts in
templates/fields/
automatically as fallback and provide the value as$value
- It will search for scripts in this order similar to
$page->render()
$givenPath/$funkyName/$pageTemplateName.php
$givenPath/$funkyName.$pageTemplateName.php
$givenPath/$pageTemplateName/$funkyName.php
$givenPath/$funkyName.php
- It is hookable to override rendering with own engine stuff
It is not (yet?) in the modules directory. Thus, I don't provide any support, but you can report bugs and errors anyway. That would be nice :)
[[nice-gallery images=1,2,3,6- type=special-kind]]
This will render the script nice-gallery.php
with the variables $images
and $type
.
Value of $type
will be "special-kind"
, value of $images
will be items 1, 2, 3 and all the rest from item 6 up to the end of the images field of that name of the page.
A variable $arguments
is also provided with all “arguments”/variables bundled.
[[hero-image pictures="description*=nice"]]
This will render the script hero-image.php
from the detected scripts folder and pull the image its description contains "nice".
[[images="description*=nice"]]
This will render the script images.php
from the detected scripts folder and pull all images which have the "nice" in their description from images field.
Then, add this Textformatter in the details tab of the desired Textfield.
added: Also matches field references inside unquoted attribute values.
fix: Fetch correct values if attribute name and attriute values field reference are the same (Always fetch value field reference).
added: A render function.
fixed: Greedy bug in regex.
added: Ability to filter field values by processwire selectors
added: Ability to pull data from page fields into attributes
other: Refactoring