1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

featurebox - more flexibility (to be used from external code mostly)

This commit is contained in:
secretr 2010-11-20 15:43:02 +00:00
parent ae3890da18
commit b8e6006bf9
3 changed files with 21 additions and 4 deletions

View File

@ -20,6 +20,8 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
* - no_fill_empty (boolean): don't fill last column with empty items (if required), default 0
* - tablestyle (string): mode to be used with <code>tablerender()</code>, default 'featurebox'
* - notablestyle (null): if isset - disable <code>tablerender()</code>
* - force (boolean): force category model load , default false
* - ids (string): comma separated id list - load specific featurebox items, default empty
*
* @param string $parm parameters
* @param string $mod category template
@ -43,7 +45,19 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
parse_str($parm, $parm);
$category = $this->getCategoryModel($ctemplate);
$category = $this->getCategoryModel($ctemplate, (vartrue($parm['force']) ? true : false));
$defopt = array(
'force' => 0,
'no_fill_empty' => 0,
'tablestyle' => 'featurebox',
'cols' => 1,
'ids' => '',
'notablestyle' => null
);
// reset to default, update current
$category->setParams($defopt)
->updateParams($parm);
if(!$category->hasData())
{
return '';
@ -51,7 +65,7 @@ class featurebox_shortcodes // must match the plugin's folder name. ie. [PLUGIN_
$tmpl = $this->getFboxTemplate($ctemplate);
$tp = e107::getParser();
$category->updateParams($parm);
$ret = $tp->parseTemplate($tmpl['list_start'], true, $category).$this->render($category, $ctemplate, $parm).$tp->parseTemplate($tmpl['list_end'], true, $category);
if(isset($parm['notablestyle']))

View File

@ -153,7 +153,8 @@ class plugin_featurebox_category extends e_model
$options = array(
'limit' => $this->getParam('limit', $this->get('fb_category_limit')),
'from' => $this->getParam('from', 0),
'random' => $this->getParam('random', $this->get('fb_category_random'))
'random' => $this->getParam('random', $this->get('fb_category_random')),
'ids' => $this->getParam('ids', '')
);
$this->_tree->load($this->getId(), $options, $force);
}

View File

@ -43,7 +43,9 @@ class plugin_featurebox_tree extends e_tree_model
$order = $this->getParam('random') ? ' ORDER BY rand()' : ' ORDER BY fb_order ASC';
$limit = $this->getParam('limit') ? ' LIMIT '.intval($this->getParam('from'), 0).','.intval($this->getParam('limit')) : '';
$qry = 'SELECT SQL_CALC_FOUND_ROWS * FROM #featurebox WHERE fb_category='.intval($category_id).' AND fb_class IN('.USERCLASS_LIST.')'.$order.$limit;
$ids = $this->getParam('ids') ? preg_replace('/[^0-9,]/', '', $this->getParam('ids')) : '';
$where = $ids ? ' AND fb_id IN('.$ids.')' : '';
$qry = 'SELECT SQL_CALC_FOUND_ROWS * FROM #featurebox WHERE fb_category='.intval($category_id).' AND fb_class IN('.USERCLASS_LIST.')'.$where.$order.$limit;
$this->setParam('db_query', $qry);
parent::load($force);