[TYPO3] Recently Updated list customization
Xavier Perseguers
typo3 at perseguers.ch
Mon Feb 11 11:40:54 CET 2008
I finally found a way to achieve my goal.
I post the solution here as I read that I am not the only person trying to get a rootline for an arbitrary page and not the current one.
HTH others...
Xavier Perseguers
> I customized the standard recently updated list of pages and I'm
> trying
> to achieving this output:
>
> - <date> : <title of page>
> Localisation : <breadcrumb leading to the page>
>
> - <date> : <title of page>
> Localisation : <breadcrumb leading to the page>
>
> ...
>
> I manage the layout with CSS as the output is done using <ul></ul> and
> items are enclosed within <li> tags.
TS to modify the behaviour of standard menu/recently updated plugin:
--- o< --- cut --- o< ---
## Customize the list of page recently updated
page.includeLibs.menustuff = fileadmin/menuFunc.inc
tt_content.menu.20.5 {
excludeUidList = current
# number of items to show + number of uid in excludeUidList
special.limit = 11
wrap = <ul id="recentlyUpdated">|</ul>
1.noBlur = 1
1.NO {
stdWrap.field = subtitle // title
ATagTitle.field = description // subtitle // title
## Prepend the date
before.field = SYS_LASTCHANGED
before.strftime = %d.%m.%Y
before.wrap = <div class="date">| :</div>
after.cObject = USER
after.cObject {
userFunc = user_menuFunc->rootline
range = 1 | -2
field = nav_title // title
wrap = <div class="breadcrumb">Localisation : |</div>
}
}
}
--- o< --- cut --- o< ---
PHP function (fileadmin/menuFunc.inc):
--- o< --- cut --- o< ---
<?php
class user_menuFunc {
// The backReference to the mother cObj object set at call time
var $cObj;
/**
* Call it from a USER cObject with 'userFunc = user_menuFunc->rootline'
*/
function rootline($content, $conf) {
// Debug informations
//t3lib_div::debug($this->cObj->data);
//t3lib_div::debug($conf);
// Retrieve the UID of the updated page
$uid = $this->cObj->data['uid'];
// Get its rootline
$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
$rootline = $GLOBALS['TSFE']->sys_page->getRootLine($uid,'');
//t3lib_div::debug($rootline);
$begin_end = explode('|', $this->conf['range']);
if (!t3lib_div::testInt($begin_end[0])) {intval($begin_end[0]);}
if (!t3lib_div::testInt($begin_end[1])) {$begin_end[1]=-1;}
$field = $conf['field'];
$field = $field ? $field : 'title';
$content = '';
$upper_limit = min(count($rootline), count($rootline) + $begin_end[1]);
for ($i = $begin_end[0]; $i < $upper_limit; $i++) {
$rootline_item = $rootline[$i];
$page_uid = $rootline_item['uid'];
$title_fields = explode('//', $field);
// Find the title field to be used
foreach ($title_fields as $f) {
$f = trim($f);
if ($rootline_item[$f]) break;
}
if ($content) $content .= ' / ';
$link = tslib_pibase::pi_linkToPage ($rootline_item[$f], $page_uid);
$content .= $link;
}
// Return the wrapped rootline
$wrap = $conf['wrap'];
return str_replace('|', $content, $wrap);
}
}
?>
--- o< --- cut --- o< ---
See it in action: http://xavier.perseguers.ch/accueil/mises-a-jour-recentes.html
More information about the TYPO3-english
mailing list