TemplateService

This service class contains functions related to templating functionality.
All public functions are available in the Twig template renderer.

Namespace

IO\Services

Properties
Type Name Description

string

$currentTemplate

Stores the id of the current template

array

$currentTemplateData

Stores data for the current template

bool

$shouldBeCached

If true, template will be cached in the content cache (Default: true)

bool

$forceNoIndex

If true, force the NOINDEX robots attribute for this template

Methods
public forceNoIndex($forceNoIndex)

Setter for the $forceNoIndex property.

Parameters

Type

Name

Description

bool

$forceNoIndex

If true, force the NOINDEX robots attribute for this template.

public isNoIndexForced():bool

Getter for the $forceNoIndex property. If true, force the NOINDEX robots attribute for this template.

public shouldBeCached():bool

Getter for the $shouldBeCached property. If true, template will be cached in the content cache

public disableCacheForTemplate()

Disable the content caching for this template

public getCurrentTemplate():string

Getter for the $currentTemplate property. Returns the id of the current template.

public setCurrentTemplate($template)

Setter for the $currentTemplate property.

Parameters

Type

Name

Description

string

$template

Identifier of a template

public isCurrentTemplate($templateToCheck):bool
Deprecated!

Use ShopUrls::is() instead

Check if the current template is same as the parameter

Parameters

Type

Name

Description

string

$templateToCheck

A template id to compare against

public isHome()
Deprecated!

Use ShopUrls::is(RouteConfig::HOME) instead

Check if the current template is the home template

public isItem()
Deprecated!

Use ShopUrls::is(RouteConfig::ITEM) instead

Check if the current template is the item template

public isMyAccount()
Deprecated!

Use ShopUrls::is(RouteConfig::MY_ACCOUNT) instead

Check if the current template is the my account template

public isCheckout()
Deprecated!

Use ShopUrls::is(RouteConfig::CHECKOUT) instead

Check if the current template is the checkout template

public isSearch()
Deprecated!

Use ShopUrls::is(RouteConfig::SEARCH) instead

Check if the current template is the search template

public isCategory()
Deprecated!

Use ShopUrls::is(RouteConfig::CATEGORY) instead

Check if the current template is the category template

public renderTemplate($template, $params):string

Render a twig template into a string

Parameters

Type

Name

Description

string

$template

A twig template to render

array

$params

Environmental data for the twig template

public isCheapestSorting():bool

Check if the price sorting returns the cheapest price