Skip to content

Commit

Permalink
[+] affichage plxShow:tagList: tri alpha, random, aucun
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane committed Sep 19, 2013
1 parent dce8780 commit a1d431e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions core/lib/class.plx.show.php
Original file line number Diff line number Diff line change
Expand Up @@ -1437,11 +1437,12 @@ public function tagFeed($type='rss', $tag='') {
*
* @param format format du texte pour chaque tag (variable : #tag_size #tag_status, #tag_url, #tag_name, #nb_art)
* @param max nombre maxi de tags à afficher
* @param order tri des tags (random, alpha, '')
* @return stdout
* @scope global
* @author Stephane F
**/
public function tagList($format='<li><a class="#tag_size #tag_status" href="#tag_url" title="#tag_name">#tag_name</a></li>', $max='') {
public function tagList($format='<li><a class="#tag_size #tag_status" href="#tag_url" title="#tag_name">#tag_name</a></li>', $max='', $order='') {
# Hook Plugins
if(eval($this->plxMotor->plxPlugins->callHook('plxShowTagList'))) return;

Expand All @@ -1466,8 +1467,23 @@ public function tagList($format='<li><a class="#tag_size #tag_status" href="#tag
}
}
}
array_multisort($array);
# limite sur le nombre de tags à afficher
if($max!='') $array=array_slice($array, 0, intval($max), true);
# tri des tags
switch($order) {
case 'alpha':
array_multisort($array);
break;
case 'random':
$arr_elem = array();
$keys = array_keys($array);
shuffle($keys);
foreach ($keys as $key) {
$arr_elem[$key] = $array[$key];
}
$array = $arr_elem;
break;
}
}
# On affiche la liste
$size=0;
Expand Down
2 changes: 1 addition & 1 deletion themes/defaut/sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</h3>

<ul>
<?php $plxShow->tagList('<li class="tag #tag_size"><a class="#tag_status" href="#tag_url" title="#tag_name">#tag_name</a></li>', 20); ?>
<?php $plxShow->tagList('<li class="tag #tag_size"><a class="#tag_status" href="#tag_url" title="#tag_name">#tag_name</a></li>'); ?>
</ul>

<h3>
Expand Down

0 comments on commit a1d431e

Please sign in to comment.