40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
function smarty_function_insert_articles($params, &$smarty)
|
|
{
|
|
$defaults = [
|
|
'count' => null,
|
|
'section' => null,
|
|
'section_id' => null,
|
|
'product_id' => null,
|
|
'related' => [],
|
|
'related_symmetric' => false,
|
|
'related_type' => false,
|
|
'tag' => null,
|
|
'assign' => null,
|
|
'order' => 'DESC',
|
|
'image' => 1,
|
|
'require_tag' => null,
|
|
'template' => 'block.articles.tpl',
|
|
];
|
|
|
|
$params = array_merge($defaults, $params);
|
|
|
|
$tmpParams = $params;
|
|
unset($tmpParams['assign']);
|
|
|
|
$smarty->loadPlugin('smarty_function_get_articles');
|
|
|
|
$data = smarty_function_get_articles($tmpParams, $smarty);
|
|
|
|
if (!empty($params['assign'])) {
|
|
$smarty->assign($params['assign'], $data);
|
|
} elseif (!empty($params['template'])) {
|
|
$_smarty_tpl_vars = $smarty->tpl_vars;
|
|
echo $smarty->_subTemplateRender($params['template'], $smarty->cache_id, $smarty->compile_id, 0, null, $data, 0, false);
|
|
$smarty->tpl_vars = $_smarty_tpl_vars;
|
|
} else {
|
|
return $data;
|
|
}
|
|
}
|