是否可以修改此代码以按相反的顺序返回类别(即最高ID?)它当前正在显示具有最低ID的输出。非常感谢提前!
$imageCols = JRequest::getVar("imageCols");
$thumbWidth = JRequest::getVar("categoryThumbWidth", 4);
$columnWidth = floor(100 / $imageCols);
$document =JFactory::getDocument();
$document->addStyleSheet('components/com_groovygallery/css/groovygallery.css');
$document->addScript( JURI::base().'components/com_groovygallery/js/modernizr.custom.84782.js' );
$document->addScript( JURI::base().'components/com_groovygallery/js/masonry.pkgd.min.js' );
<?php if($this->params->get('show_page_heading')){?><h2><?php echo $this->params->get('page_heading');?></h2><?php } ?>
<div id="groovyGalleryCats" data-masonry-options='{ "columnWidth": 200, "itemSelector": ".groovyGalleryCat" }'>
<?php
foreach($this->categories as $key=>$category){
$params = json_decode($category->params);
$catImage = JURI::base().$params->image;
?>
<a class="groovyGalleryCat" href="<?php echo JRoute::_('index.php?option=com_groovygallery&view=images&filter_category='.$category->id); ?>" >
<?php if($params->image){ ?><img src="<?php echo JURI::base().'components/com_groovygallery/timthumb.php?src='. $catImage . '&zc=2&w='.$thumbWidth;?>" alt="<?php echo $category->title;?>" /> <?php } ?>
<?php echo $category->title;?>
<?php //echo $category->description;?>
</a>
<?php
}
?>
</div>
<style>
a.groovyGalleryCat {width:<?php echo $columnWidth;?>%;}
</style>
<script src="<?php echo JURI::base().'components/com_groovygallery/js/init-cat.js'; ?>" defer="defer"></script>
答案 0 :(得分:0)
您可以像这样重新排序数组(假设id属性是public ...):
uasort($this->categories, function($a, $b) {
return $a->id > $b->id ? -1 : 1;
});