Skip to content

Templating

Context

Specific context is injected for every specific template but global functions and context are available:

  • app, application context
    • request, current request
      • uri, full requested uri
  • wf_cms_publicUrl, public base site url

Extensions

Functions

  • modules_lens(modules, 'title.content'), return the node following the given path or null if not exists.
  • modules_traverse($modules, $state, $f, $role = null), traverse the modules tree enabling folding data, $f can be a function with signature function ($node, $state, $role) { return ... new state ...; } or a string defining only the body of that function, i.e. 'return ... new state ...;
  • countModulesWords(modules), count the words following the word-count-config settings.
  • xgo_get_page_by_slug(slug), return the page object from their slug value.
  • xgo_get_tag_by_slug(slug), return the tag object from their slug value.
  • xgo_get_category_by_slug(slug), return the category object from their slug value.
  • xgo_get_root_categories(), return all root (active) categories.
  • page_count_content_models_type(modules, type), count how many times appear the content type.
  • wf_render_twig_template(template_name, context), render the given template using the given context.
  • wf_load_image_by_sourceId(source_id), return the image object from their source_id field.
  • xgo_facet(), infer the current facet
  • xgo_facet_isAmp(), true if the current facet is AMP
  • page_get_article_body(page)', get the body from a page to a string
  • xgo_download_url(url), download (maximum 5 seconds) an external resource.
  • url_decode(url), bypass to urldecode.
  • url_encode(url), bypass to urlencode.
  • preg_replace(pattern, replacement, subject), bypass to preg_replace.
  • xgo_get_tag_by_id(id), return the tag object from their id value.
  • wf_setting_json_array_or(settingSlug, defaultArray = null): ?array, read the setting and convert to json array using default if not settled.
  • xgo_taghandler_add(['string']), adds cache xkeys, input example ['x-key-1', 'x-key-2']

Filters

  • md5, compute the MD5 value.
  • html2text, convert to plain text the HTML value.
  • text2htmlattr, escapes special characters and encodes them based on $charset.