[TYPO3-mvc] Possibility to let Extbase-Ext return an array?
Joerg Schoppet
joerg at schoppet.de
Fri Jun 19 16:33:36 CEST 2009
Hi,
Bastian Waidelich schrieb:
> I've just tried it out by creating a 2nd level menu with all available
> Blogs in the blog_example.
> If you want to try it out yourself, just follow this little
> mini-tutorial (:
>
> 1. create a class "class.tx_blogexample_menuitem_procfuncs.php" with
> following content:
>
> <?php
> class tx_blogexample_menuitem_procfuncs {
>
> public function createBlogMenuItems($menuArr, $conf) {
> $this->blogRepository =
> t3lib_div::makeInstance('Tx_BlogExample_Domain_Model_BlogRepository');
> $blogs = $this->blogRepository->findAll();
> foreach ($blogs as $blog) {
> $queryParams = '&tx_blogexample_pi1[blog][uid]=' .
> (integer)$blog->getUid() .
> '&tx_blogexample_pi1[action]=index&tx_blogexample_pi1[controller]=Post';
> $queryParams.=
> '&cHash='.t3lib_div::shortMD5(serialize(t3lib_div::cHashParams($queryParams)));
>
> $item = array(
> 'uid' => $conf['targetPid'],
> 'title' => $blog->getName(),
> '_ADD_GETVARS' => $queryParams,
> $item['ITEM_STATE'] = 'NO'
> );
> $menuArr[] = $item;
> }
>
> return $menuArr;
> }
> }
> ?>
>
> 2. Add following TS to your menu setup:
>
> includeLibs.tx_blogexample_menuitem_procfuncs =
> EXT:blog_example/class.tx_blogexample_menuitem_procfuncs.php
>
> lib.myMenu = HMENU
> lib.myMenu {
> 1 = TMENU
> 1 {
> wrap = <ul> | </ul>
> NO.wrapItemAndSub = <li> | </li>
> }
> 2 < .1
> 2 {
> itemArrayProcFunc =
> tx_blogexample_menuitem_procfuncs->createBlogMenuItems
> itemArrayProcFunc {
> targetPid = {$blogIndexPid}
> }
> }
> }
>
> 3. set blogIndexPid to a uid containing the blog_example in your TS
> constants
>
thanks a lot, works like a charm :-D
Joerg
More information about the TYPO3-project-typo3v4mvc
mailing list