Projets « Horizontal drop-down menu « Analyse fonctionnelle «
Analyse fonctionnelle
| Next » |
je me demandais si il était vraiment nécessaire de rajouter une fonction à la classe Page ?
un simple layout passé en paramètre à la fonction Page::tabs ne serait-il pas suffisant ?
Il suffirait ensuite d'utiliser ce layout au lieu de "tabs" (que l'on garde en valeur par défaut) lors de l'appel à la fonction Sections::list_by_title_for_anchor.
Nous aurions comme modif de page.php :
un simple layout passé en paramètre à la fonction Page::tabs ne serait-il pas suffisant ?
Il suffirait ensuite d'utiliser ce layout au lieu de "tabs" (que l'on garde en valeur par défaut) lors de l'appel à la fonction Sections::list_by_title_for_anchor.
Nous aurions comme modif de page.php :
function tabs($with_home=TRUE, $with_reverse=FALSE, $prefix=NULL, $suffix=NULL [b],$layout='tabs'[/b]) {
global $context;
// only for live servers
if(!file_exists($context['path_to_root'].'parameters/switch.on'))
return;
// we have no database back-end
if(!is_callable(array('sql', 'query')))
return;
// cache this across requests
$cache_id = 'skins/page.php#tabs';
if(!$text =& Cache::get($cache_id)) {
// an array of tabs
$site_bar = array();
// prefix tabs, if any
if(is_array($prefix) && count($prefix))
$site_bar = array_merge($site_bar, $prefix);
// the first tab links to the front page
if($with_home && is_callable(array('i18n', 's')))
$site_bar = array_merge($site_bar, array($context['url_to_root'] => array('', i18n::s('Home'), '', 'home')));
// default number of sections to list
if(!isset($context['root_sections_count_at_home']) || ($context['root_sections_count_at_home'] < 1))
$context['root_sections_count_at_home'] = 5;
// query the database to get dynamic tabs
if(is_callable(array('Sections', 'list_by_title_for_anchor')) && ($items =& Sections::list_by_title_for_anchor(NULL, 0, $context['root_sections_count_at_home'], [b]$layout[/b])))
$site_bar = array_merge($site_bar, $items);
// suffix tabs, if any
if(is_array($suffix) && count($suffix))
$site_bar = array_merge($site_bar, $suffix);
// the skin will reverse the order
if($with_reverse)
$site_bar = array_reverse($site_bar);
// shape tabs
$text =& Skin::build_list($site_bar, 'tabs')."\n";
Cache::put($cache_id, $text, 'sections');
}
echo $text;
}
This comment has inspired:
- Alexis Raimbault on June 15 2010 - Christophe Battarel : effectivement, qui peut le plus peut le ...
by Christophe Battarel on June 15 2010










