Custom Template

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
mathiass
Posts: 2
Joined: 02 Mar 2016, 00:48

Custom Template

Post by mathiass » 02 Mar 2016, 00:57

Hello community!

Aimeos seems to me a very interesting project. But the documentation is a bit confusing when referring to overwriting views.

Someone has a tutorial or I could give a guide on how to do?

Thank you. :)

User avatar
aimeos
Administrator
Posts: 3114
Joined: 01 Jan 1970, 00:00

Re: Custom Template

Post by aimeos » 02 Mar 2016, 09:50

The views itself are pretty straight forward: Just HTML with alternative PHP syntax.

You have access to all data that has been assigned by the HTML client which renders the view as well as all data that has been assigned by parent HTML clients, e.g.

|Client/Html/Catalog/Detail/Standard
| => template: catalog/detail/body-default.php
| => assigns: detailProductItem, detailProductMediaItems, etc.
|- Client/Html/Catalog/Detail/Basket/Standard
| => template: catalog/detail/basket-body-default.php
| => assigns: basketStockUrl, etc.
|-- Client/Html/Catalog/Detail/Basket/Selection/Standard
| => template: catalog/detail/basket-selection-body-default.php
| => assigns: selectionProducts, selectionAttributeItems, etc.

In the template of the selection HTML client, you have now access to selectionProducts, selectionAttributeItems, basketStockUrl, detailProductMediaItems, detailProductItem. You should have a look into the templates and the HTML clients to find out which data they assign.

To access the data in the view, you can use

Code: Select all

$this->get( 'selectionProducts', array() );   // second parameter is the default value if not available
$this->selectionProducts;   // (throws an exception if not available)
Additionally, there are some view helpers available. They are located in:
https://github.com/aimeos/aimeos-core/t ... iew/Helper

To use the view helpers in the view, call e.g.

Code: Select all

echo $this->url( $target, $controller, $action, $params, $trailing, $config );
The example prints the generated URL for the given parameters. Use lower-case for all view helpers, i.e. "url()" for the view helper in the "Url" directory. The parameters for each view helper varies, so so should have a look into the interface or implementation of the view helper you want to use.

These are the view helpers that are available:
* block: Extend from parent templates like in Blade or Twig
* config: Access to the configuration settings
* content: Generate media URL
* csrf: CSRF security for form posts
* date: Localized dates
* encoder: Quoting output to avoid security breaches
* formparam: Generates values for the "name" attribute of input elements
* mail: Access to an e-mail message that can be filled
* number: Localized number format
* param: Access to get/post/url parameters
* partial: Renders the given sub-template
* request: PSR-7 request object
* response: PSR-7 response object
* url: Generates URLs
* value: Access values in multi-dimensional arrays in a simple way

Hope that helps a bit :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

mathiass
Posts: 2
Joined: 02 Mar 2016, 00:48

Re: Custom Template

Post by mathiass » 02 Mar 2016, 13:04

For Laravel is the same?

User avatar
aimeos
Administrator
Posts: 3114
Joined: 01 Jan 1970, 00:00

Re: Custom Template

Post by aimeos » 02 Mar 2016, 13:08

Yes, the templates are shared in all environments (Laravel, Symfony, Flow, TYPO3, etc.)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

User avatar
aimeos
Administrator
Posts: 3114
Joined: 01 Jan 1970, 00:00

Re: Custom Template

Post by aimeos » 02 Mar 2016, 17:57

This article contains now detailed information and examples about the view helpers too:
https://aimeos.org/docs/Developers/Html ... iew_helper
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply