[TYPO3-dev] New Extension does not show anything

Anja Leichsenring aleichsenring at ab-softlab.de
Sun Jun 29 22:47:39 CEST 2014


Hi Dirk,

I take your code as a example for usage, otherwise I would need to write 
a book now.

First of all, you need a TypoScript Template, what the extension_builder 
should have generated for you. This you need to add to your root 
template, and set at least the PID in setup or constants, where your 
records are stored and looked for.

In your list action, you create a new instance, but you never add it to 
the repository, so no call to the persistence manager will do any good. 
I add the missing line in your code below.

After this, you should see your categories.

Hope this helps.
Kind regards
Anja

On 29.06.2014 21:59, Dirk Ho wrote:
> Hi all,
>
> I tried to create a new extension with the Extension Builder extension.
>
> Aggregate Root is a Model called "Category", having a n:1 relation to
> "Forum" ("Forum has a n:1 relation to "Topic", "Topic" has a n:1
> relation to "Post").
>
> I added the extension "Forumlisting" to a page named "Forum". When I now
> call "Forum" nothing is shown (except the page's template). I already
> cleared Cache,... but it didn't work.
>
> Any idea, what I do wrong? When i put file_put_contents to
> CategoryController's list method this file is not written.
> /var/log/apache2/error.log does not show any error.
>
> Beneath I posted some code/config information. Do you need additional
> information?
>
> Thanks and best wishes,
>
> Dirk
>
> My ext_localconf.php looks like that:
> <?php
> if (!defined('TYPO3_MODE')) {
>          die('Access denied.');
> }
>
> \TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
>          'DH.' . $_EXTKEY,
>          'Forumlisting',
>          array(
>                  'Category' => 'list',
>
>          ),
>          // non-cacheable actions
>          array(
>                  'Category' => 'list',
>
>          )
> );
>
> My Category Controller looks like:
>
> <?php
> namespace DH\Forum\Controller;
> /**
>   * CategoryController
>   */
> class CategoryController extends
> \TYPO3\CMS\Extbase\Mvc\Controller\ActionContro$
>
>          /**
>           * categoryRepository
>           *
>           * @var \DH\Forum\Domain\Repository\CategoryRepository
>           * @inject
>           */
>
>          /**
>           * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
>           * @inject
>           */
>          protected $persistenceManager;
>
>
>          /**
>           * action list
>           *
>           * @return void
>           */
>          public function listAction() {
>
> file_put_contents('/var/www/supporters-karlsruhe.de/log.log', 'TEST');
>
>              for ($i = 0; $i <= 3; $i++) {
>                $category =
> $this->objectManager->get('\\DH\\Forum\\Domain\\Model\\Category');
>                $category->setTitle('A'.$i);
>                $category->setDescription('A');
>                $category->setOrderId($i);
>                $category->setCreatedAt(now());

$this->categoryRepository->add($category);

>              }
>
>              $this->persistenceManager->persistAll();
>
>              $categories = $this->categoryRepository->findAll();
>              $this->view->assign('categories', $categories);
>          }
> }
>
>
> My Resources\Private\Template\Category\List.html looks like
> <ul class="category-list">
>    <f:for each="{categories}" as="category}>

here is a " missing, right after category

>      <li>{category.title}</li>
>    </f:for>
> </ul>




More information about the TYPO3-dev mailing list