Skip to content

Commit

Permalink
Merge pull request magento#5854 from drpayyne/patch-34
Browse files Browse the repository at this point in the history
Added example for using block argument in template
  • Loading branch information
dobooth authored Oct 28, 2019
2 parents 5efcdc8 + 32d528c commit 80d15ae
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions guides/v2.2/frontend-dev-guide/templates/template-override.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,21 @@ Unlike other templates, `root.phtml` contains the `doctype` specification and co

## Getting argument values from layout {#getter}

Arguments values set in a layout file are accessed in templates using the `get{ArgumentName}()` and `has{ArgumentName}()` methods.
Arguments values set in a layout file are accessed in templates using the block's `get{ArgumentName}()` and `has{ArgumentName}()` methods.

See [Layout instructions]
For example, set an argument in the block: `<argument name="store_name" xsi:type="string">OrangeCompany</argument>`.

* Get the argument value, in the template:

* `$block->getData('store_name')`
* `$block->getStoreName()`

* Check if the argument exists:

* `$block->hasData('store_name')`
* `$block->hasStoreName()`

See [Block arguments] for more information.

## Using PHP short tags in template PHTML files {#short-tags}

Expand All @@ -88,4 +100,4 @@ is the same as writing
[`app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml`]: {{ site.mage2bloburl }}/{{ page.guide_version }}/app/code/Magento/Catalog/view/frontend/layout/catalog_category_view.xml
[Child theme]: {{ page.baseurl }}/frontend-dev-guide/themes/theme-inherit.html
[Theme inheritance]: {{ page.baseurl }}/frontend-dev-guide/themes/theme-inherit.html#theme-inherit-templates
[Layout instructions]: {{ page.baseurl }}/frontend-dev-guide/layouts/xml-instructions.html
[Block arguments]: {{ page.baseurl }}/frontend-dev-guide/layouts/xml-instructions.html#argument

0 comments on commit 80d15ae

Please sign in to comment.