List of Pages Recently Updated

This article explains how to get a list of pages recently updated just as the one of this website; that is, with the update date and the breadcrumb menu to the page. I think this is useful as only showing the title of the page is not enough, its context gives much more information.

Let’s start adding plugin Menu/Sitemap to the page of your website that should contain the list of pages recently updated:

Then choose type of menu “Recently updated pages” and define the Starting point to the root of your website.

We will now modify the behaviour of the menu generation in order to prefix all pages with their last modification date and suffix them with a breadcrumb menu. Let’s add following code to your templateTS:

    ## 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
        # pages must have been updated within the last three days (3600*24*3)
    special.maxAge = 3600*24*3
    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">|&nbsp;:</div>&nbsp;
 
        after.cObject = USER
        after.cObject {
            userFunc = user_menuFunc->rootline
 
            range = 1 | -2
            field = nav_title // title
            wrap = <div class="breadcrumb">Localisation&nbsp;:&nbsp;|</div>
        }
    }
}

Now create file fileadmin/menuFunc.inc:

<?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 and the language
        $data = $this->cObj->data;
        $uid = $data['uid'];
        $language = $data['_PAGES_OVERLAY'] ? $data['_PAGES_OVERLAY'] : 0;
 
            // 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('|', $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'];
                // Is there a translation to be found?
            if ($language) {
                $item = $GLOBALS['TSFE']->sys_page->getPageOverlay($page_uid, $language);
                if ($item) $rootline_item = $item;
            }
 
            $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);
    }
}
?>

You still just have to customize your CSS stylesheet to adapt the size and position of the elements!

Flattr