-
Notifications
You must be signed in to change notification settings - Fork 0
Templating
A special class TemplateHelper (Template facade) is created to easily create new layouts (useful for extensions).
I highly recommend you to read the PHPDocs for each method and to test it, since it will be quite difficult to explain it without the possibility to demonstrate the results.
Method pageParams() lets you easily create a button menu for page parameters.
e.g. I want to be able to change the number of records per page like in the picture below.
For this simply insert this into your view: {{ Template::pageParams('Per Page', 'perPage', [10, 20, 30, 40] ) }}
- First parameter (
'Per Page') can also be a lang key invendor/atorscho/backend/src/lang/en/labels.php':'perPage'instead of'Per Page'`. It will first search for a key, if it exists it returns the translated string otherwise the parameter itself. - The second parameter is the key used in URI:
/admin/articles?perPage=20. - The last parameter, as you might guess, is an array of parameters. If you want to have a translated string, write it like this:
['key' => trans('file.key'), 'anotherKey' => trans('file.key2')]. This way the value in URI will stay in latin lowercase letters, but in HTML will be capitalized and translated (if needed).
Note
Since perPage parameter is often used, simply put this in your view: {{ Template::perPageRecordsParams() }}. It does exactly the same thing.
Another Note
If you need to specify parameters to the title, replace the first parameter with ['perPage', 'paramKey' => 'Param Value']. It pulls the first value out of the array and uses it as a title, and the rest of it as an array of parameters. Exactly what is needed.
