39 lines
885 B
PHP
39 lines
885 B
PHP
<?php
|
|
|
|
/*
|
|
* Smarty plugin
|
|
* -------------------------------------------------------------
|
|
* Type: function
|
|
* Name: get_slider
|
|
* Purpose: get a slider of known name or id
|
|
* -------------------------------------------------------------
|
|
*/
|
|
|
|
use KupShop\ContentBundle\Util\SliderUtil;
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
|
|
function smarty_function_get_slider($params, &$smarty)
|
|
{
|
|
$random = false;
|
|
|
|
extract($params);
|
|
|
|
$sliderUtil = ServiceContainer::getService(SliderUtil::class);
|
|
|
|
$slider = null;
|
|
|
|
if (isset($id)) {
|
|
$slider = $sliderUtil->get((int) $id, (bool) $random);
|
|
} elseif (isset($name)) {
|
|
$slider = $sliderUtil->getByName($name, (bool) $random);
|
|
}
|
|
|
|
if (!$slider) {
|
|
echo "Neexistující slider '{$name}'";
|
|
}
|
|
|
|
if (!empty($assign)) {
|
|
$smarty->assign($assign, $slider);
|
|
}
|
|
}
|