[TYPO3-mvc] footer equivalent for addAdditionalHeaderData

Sebastian Schreiber me at schreibersebastian.de
Tue Nov 22 14:23:58 CET 2011


Hi Kerstin,
write your own ViewHelper and use all of the available functions of 
t3lib_pageRenderer.
As it is a Singleton you don´t have to worry about performance issues:

Something like this:

class Tx_MyExt_ViewHelpers_Meta_AddJsFooterInlineCodeViewHelper extends 
Tx_Fluid_Core_ViewHelper_AbstractViewHelper {

     /**
      * renders a special title for the page
      *
      * @param string $name
      * @param string $file
      * @return string $content: The pagebrowser
      */
     public function render($name, $script = NULL) {
         if ($script === NULL) {
             $script = $this->renderChildren();
         }
         $script = $this->removeScriptTags($script);
         if ($this->controllerContext->getRequest()->isCached()) {
             // Makes no sense to use the DPI
             $pageRenderer = t3lib_div::makeInstance('t3lib_PageRenderer');
             /* @var $pageRenderer t3lib_PageRenderer */
             $pageRenderer->addJsFooterInlineCode($name, $script);
         }
     }
}


In order to get it working, your site has to be cached. As far as i know.

Hope that points you to the right direction.

Am 22.11.2011 13:37, schrieb Kerstin Eitner:
> Hi Tim,
>
> at my case i don't have to place the plugin more than once per page 
> (even if that would be great), but i have an option called "autoplay" 
> which decides if the slider should start automatically or not.
>
> [..]
> $data = $this->request->getContentObjectData();
> $plugin_uid = $data['uid'];
>
> $autoplay = $this->settings['slider_autoplay'];
> <script type="text/javascript">
>     jQuery(document).ready(function(){
>          jQuery("#slider_c' . $_uid . '").start({autoPlay: ' . 
> $autoplay . '});
>     });
> </script>
>
>
> In a file outside my extension i don't have access to 
> $this->settings['slider_autoplay'].
>
> The value for the $_uid is already solved and displayed right.
> I need a solution how to put that js-call within my extension to the 
> footer, so that it can be minified like the rest of my js.
>
>
> Somebody any other ideas?
>
> Greetings,
> Kerstin
>
>
>
>
> Am 20.11.2011 23:28, schrieb Tim Schoch | GSTALTIG:
>> if you dont want to place the plugin more then once per page, you can 
>> set the uid in fluid.
>> <script>var yourUid = {uid}</script>
>> And it will be present in the javascript file.
>> You can test that with alert( yourUid );
>> (or console.log, if you use it)
>>
>> Tim
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


-- 
Sebastian Schreiber
(Medieninformatiker B.Sc.)
(TYPO3 Certified Integrator)

Schanzenstraße 27, Schlosserei 4
D-51063 Köln

T  0221 677 88 541
M  0176 431 05 790

Skype schreibersebastian.de

me at schreibersebastian.de
www.schreibersebastian.de

Steuernummer: 217 / 5269 / 4675



More information about the TYPO3-project-typo3v4mvc mailing list