This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
In the Markup Guide it states that "October extends Twig engine with a number of functions, tags, filters and variables.", does anyone know where these can be found?
For example, I've used the {{ product.image.thumb(200, auto) }}
function on an outputted image to create a 200px wide thumbnail, but can't find anywhere in the docs etc where this is defined, I think I just stumbled across it by accident and I'm assuming it references the getThumb()
PHP function, but can't find where this is all linked in the docs.
I've looked in the modules/cms/twig/Extension.php
file where there are a number of extensions/functions defined, but not the thumb
function above, so I'm just wondering if there are any other functions like crop
, scale
etc for images, along with maybe some other functions for other elements defined elsewhere?
Last updated
PS, this is what get outputted into the rendered twig_template
:
echo twig_escape_filter($this->env, $this->getAttribute($this->getAttribute((isset($context["product"]) ? $context["product"] : null), "image"), "thumb", array(0 => 200, 1 => (isset($context["auto"]) ? $context["auto"] : null)), "method"), "html", null, true);
if it helps anyone? You can see the thumb
get outputted as a method with the array of options.
Last updated
The most important thing to learn about Twig is how it accesses the PHP layer. For convenience sake {{ foo.bar }}
does the following:
- check if
foo
is an array andbar
a valid element - if not, and if
foo
is an object, check thatbar
is a valid property - if not, and if
foo
is an object, check thatbar
is a valid method (even if bar is the constructor - use __construct() instead) - if not, and if
foo
is an object, check thatgetBar
is a valid method - if not, and if
foo
is an object, check thatisBar
is a valid method - if not, return a
null
value.
1-4 of 4