[TYPO3-dev] New Extension does not show anything

Dirk Ho dirk_studivz at web.de
Mon Jun 30 19:38:55 CEST 2014


Hi again,

I'm sorry for disturbing again.

I added Anjas hint ot my CategoryController class. The template is also 
added to my root template.

What I do not have, yet, is the TypoScript I (seem to) need. In my book, 
they do not show, how this TypoScript should look like for the folder, 
the Category objects are stored in. In the books example the new 
generated elements can be found on the same page as the Extension (the 
one I call in the frontend, in my case the "Forum" page).

But when I use "List" view in the Backend (Typo3 6.2) they do not seem 
to be stored. Calling the "Forum" page I get an error

"Found an invalid element type declaration in %s. A type "''" does not 
exist."

Perhaps the problem is, that these objects are not stored anywhere?!

Can you help me with the TypoScript for the folder I store my Objects in?

Another problem is, if I want to use php objects or methods like 
DateTime or now() I get the message, that it cannot be found in 
DH\Forum\Controller\DateTime - of course. If I try to put an annotation 
above the variable like
/**
  * @var \DateTime
  */
$data = new DateTime();

Nevertheless I cannot use the DateTime object.

How do I have to use php objects/methods?

Thanks and best wishes,

Dirk

Am 29.06.2014 22:47, schrieb Anja Leichsenring:
> 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