first commit
This commit is contained in:
38
class/smarty_plugins/function.get_slider.php
Normal file
38
class/smarty_plugins/function.get_slider.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user