[TYPO3-formidable] Show header on LISTER
dpino
dpino at igalia.com
Mon Oct 17 13:14:04 CEST 2011
Hi,
I was looking for a way of adding a header to a LISTER. The idea is to
show a header that could stand for the name of a listing. For instance,
imagine I have a LISTER for showing car models from a brand of cars. I
would like to show before the list the name of the brand for that list
of cars. However, the name of the brand is not fixed, depends on a GET
parameter.
I didn't find anything in the LISTER API to do this so I added a new
field to LISTER called <header>. This new field works at the same level
as <ifempty> or <message>. The header is always shown on top, right
before the listing rows. It supports either literal strings or php code.
Here is an example on how to use it.
<header>
<userobj>
<php><![CDATA[
$ttBrand = t3lib_div::_GET('tx_brand');
$brand_uid = $ttBrand['uid'];
$brand_name = tx_myhelper_div::getBrandName($brand_uid);
return "<h2>$brand_name</h2>";
]]></php>
</userobj>
</header>
Please, find the patch attached. It would be nice if it could be
integrated in the main trunk at some point as I think this functionality
is often required (the other way of doing the same thing would be to
create a FE plugin which reused the formidable template, AFAIK).
Regards,
Diego
-------------- next part --------------
From dcc7dbb4944480b3441699c4fe09aa5dd4105b4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Diego=20Pino=20Garc=C3=ADa?= <dpino at igalia.com>
Date: Mon, 17 Oct 2011 19:34:18 +0900
Subject: [PATCH] Modified Formidable to support field 'header' on LISTER
---
.../api/base/rdt_lister/api/class.tx_rdtlister.php | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/typo3conf/ext/ameos_formidable/api/base/rdt_lister/api/class.tx_rdtlister.php b/typo3conf/ext/ameos_formidable/api/base/rdt_lister/api/class.tx_rdtlister.php
index 3cb0eb3..bda19b9 100644
--- a/typo3conf/ext/ameos_formidable/api/base/rdt_lister/api/class.tx_rdtlister.php
+++ b/typo3conf/ext/ameos_formidable/api/base/rdt_lister/api/class.tx_rdtlister.php
@@ -380,10 +380,21 @@ class tx_rdtlister extends formidable_mainrenderlet {
}
}
+ function _renderList_header(&$aTemplate) {
+ $header = $this->_navConf("/header");
+ if (!empty($header)) {
+ if ($this->oForm->isUserObj($header)) {
+ $header = $this->oForm->_callUserObj($header);
+ }
+ $aTemplate["html"] = $header.$aTemplate["html"];
+ }
+ }
+
function &_renderList(&$aRows) {
$aTemplate = $this->_getTemplate();
+ $this->_renderList_header($aTemplate);
$this->_renderList_displayRows($aTemplate, $aRows);
$this->_renderList_displayPager($aTemplate);
$this->_renderList_displaySortHeaders($aTemplate);
@@ -1246,4 +1257,4 @@ ERRORMESSAGE;
if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/ameos_formidable/api/base/rdt_lister/api/class.tx_rdtlister.php"]) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/ameos_formidable/api/base/rdt_lister/api/class.tx_rdtlister.php"]);
}
-?>
\ No newline at end of file
+?>
--
1.7.6.2
More information about the TYPO3-project-formidable
mailing list