Currently I am using arfooo as a directory on my website. On the index page of that website the entries in the directory are displayed in random based on the following code…
sitecontroller.php
[php]/**
* Get random sites on index page
*/
function randomListAction()
{
$cache = Cacher::getInstance();
//get last time generated
$generationDate = Config::get('selectionGenerationDate');
$period = Config::get('selectionPeriod');
$todayDate = date("Y-m-d");
//if doesn't exists last refresh or is overtime
$refreshNeeded = (!preg_match('#^[0-9]{4}-[0-9]{2}-[0-9]{2}$#', $generationDate) || strtotime($generationDate . "+" . $period . " days") <= strtotime($todayDate));
$cacheItemName = "indexRandomSites" . Config::get("language") . "Template" . Config::get("templateName");
//if force refresh or cache donesn't exists
if ($refreshNeeded || ($indexRandomSitesHtml = $cache->load($cacheItemName, false)) === null) {
$data = $this->siteList->getIndexRandomList($refreshNeeded);
$this->set("randomSites", $data);
$indexRandomSitesHtml = $this->render();
$cache->save($indexRandomSitesHtml, $cacheItemName, false, array("site", "setting"));
}
return $indexRandomSitesHtml;
}[/php]
randomlist.tpl
{foreach from=$randomSites value=site}
<a href="{$site|objurl:'siteDetails'}" class="link_black_blue_b_u">{$site.siteTitle}</a>
{/foreach}
index.tpl
[code]
{'mainIndex_h2'|lang}
The problem is I no longer want the entries to be displayed randomly but rather in alphabetical order based on siteTitle. But clicking siteTitle still needs to open siteDetails as seen in randomlist.tpl
I have put a lot time into this and am now more confused than when I started. Any help would be greatly appreciated…