https://github.com/friendsofshopware/froshtemplateextensions
This plugin allows you to use additional template extensions
https://github.com/friendsofshopware/froshtemplateextensions
Last synced: 12 months ago
JSON representation
This plugin allows you to use additional template extensions
- Host: GitHub
- URL: https://github.com/friendsofshopware/froshtemplateextensions
- Owner: FriendsOfShopware
- License: mit
- Created: 2019-03-05T22:29:54.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2023-02-25T14:45:18.000Z (over 3 years ago)
- Last Synced: 2025-04-03T17:47:05.448Z (over 1 year ago)
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FroshTemplateExtensions
[](https://gitter.im/FriendsOfShopware/Lobby)
The idea behind this plugin is to provide useful functions for theme developers in smarty.
## Current available functions
### Thumbnail
You generate with this function for every uploaded image custom thumbnails.
Following parameters are available
* id / path
* width
* height
* keepProportion
* quality
All images are generated using Shopware default Thumbnail Generator. So also all images are optimized
Examples
```
```
```
```
### Fetch
Fetch data from the database using the functions:
* `fetchOne` - fetches a single value from the specified column of a row
* `fetchRow` - fetches the first row from the specified table
* `fetchAll` - fetches all rows from the specified table
The following parameters are available
* `var` - required for `fetchRow` and `fetchAll`, defines the variable the resulting array will be stored in
* `select` - may either be of type `string` or `array`, specifies the columns to be fetch, required for `fetchOne`
* `from` - required for all functions, specifies the table to be fetched from
* `where` - must be of type `array`, must contain key value pairs in the format of `'[column][operand]' => value`
* `order` - must be of type `array`, must contain key value pairs in the format of `'[column]' => '[ASC][DESC]'`
* `offset` - must be of type `integer`, sets the offset for the first result
* `limit` - must be of type `integer`, sets the limit of results
Examples
```smarty
{* Fetches the price of the last article added to basket of the current user *}
{fetchOne select="price" from="s_order_basket" where=["modus =" => 0, "sessionID =" => $smarty.session.Shopware.sessionId] order=["id" => "DESC"]}
{* Fetches the 5th to 15th row of s_articles *}
{fetchAll var="articles" from="s_articles" offset=5 limit=10}
{foreach $articles as $article}
Article: {$article.name} - {$article.description}
{/foreach}
{* Fetches the last order's id and ordernumber *}
{fetchRow var="order" select=["ordernumber", "id"] from="s_order" where=["status !=" => -1] order=["ordertime" => "DESC"]}
{$order.id} - {$order.ordernumber}
```
*Please note:* The fetch functions need to be actived through the configuration of the plugin. They are disabled by default.
Before activating the fetch functions, please make sure, that none of your changes to your theme allow for unsanitized user
inputs to be compiled as smarty.
## Requirements
- Shopware 5.5
## Installation
- Download latest release
- Extract the zip file in `shopware_folder/custom/plugins/`
## Contributing
Feel free to fork and send pull requests!
## Licence
This project uses the [MIT License](LICENCE.md).