Hallo zusammen,

ich versuche gerade eine Extension mittels Extbase und Fluid zu erstellen, die 
es mir erlaubt Bilder zu kommentieren.

Dazu habe ich zwei Models erzeugt "Image" und "Comment".

Leider gelingt es mir nicht einen neuen Kommentar über die Action "Create" im 
CommentController hinzuzufügen.

createAction:

/**
         * action create
         *
         * @param \Hg\Commentgallery\Domain\Model\Comment $newComment
         * @param \Hg\Commentgallery\Domain\Model\Image $image
         * @return void
         */
        public function createAction(
                \Hg\Commentgallery\Domain\Model\Comment $newComment,
                \Hg\Commentgallery\Domain\Model\Image $image
        ) {     
                $image->addComment($newComment);
                $this->redirect('show', 'Image', NULL, $arr = array("image" => 
$image));
        }


Dabei sieht die addComment-Funktion im Image-Model wie folgt aus:

        /**
         * Adds a Comment
         *
         * @param \Hg\Commentgallery\Domain\Model\Comment $comment
         * @return void
         */
        public function addComment(\Hg\Commentgallery\Domain\Model\Comment 
$comment) {
                $this->comments->attach($comment);
        }


Comments ist ein Objectstoreage:

/**
         * comments
         *
         * @var 
\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Hg\Commentgallery\Domain\Model\Comment>
         */
        protected $comments;



dazu gibt es die initStoreageObjects-Funktion:

/**
         * Initializes all ObjectStorage properties.
         *
         * @return void
         */
        protected function initStorageObjects() {
                $this->comments = new 
\TYPO3\CMS\Extbase\Persistence\ObjectStorage();
        }


und so sieht die Fluid-Anzeige des Bildes mit Formularfeldern zur Eingabe eines 
neuen Kommentares aus:

<f:image src="{image.file.originalResource.publicUrl}" alt="" width="400"/>

<h3>Kommentar hinzufügen</h3>

<f:form controller="Comment" action="create"  name="newComment" object="{newComment}" 
arguments="{image:image}">        
        <f:render partial="Comment/FormFields" />       
        <f:form.submit value="Absenden" />
</f:form>

<f:for each="{image.comments}" as="comment">
        <div style="padding: 10px; margin-bottom:10px; background-color: #f0f0f0; 
width: 300px;">
                <p>{comment.author}</p>
                <p>{comment.text}</p>
        </div>
</f:for>


Hat jemand einen Tipp?

Vielen Dank vorab & viele Grüße
Steeeve
_______________________________________________
TYPO3-german mailing list
TYPO3-german@lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german

Antwort per Email an