TYPO3 Flow Base DistributionPackagesApplications

Suggestion #8882

AddToHtmlHead

Added by Adrian Föder about 5 years ago. Updated about 3 years ago.

Status:New Start date:2010-07-15
Priority:Could have Due date:
Assigned To:- % Done:

0%

Category:-
Target version:-
Has patch: Tags:

Description

Just a suggestion and I don't know if it does exist already in another case; but here's a ViewHelper i've just written for a custom project:

    /**
     * Render the head addition
     *
     * @param string $key the key for additionalHeaderData; useful for overriding
     * @return void
     */
    public function render($key = NULL) {
        $textToAdd = $this->renderChildren();

        if($key !== NULL) {
            $GLOBALS['TSFE']->additionalHeaderData[$key] = $textToAdd;
        } else {
            $GLOBALS['TSFE']->additionalHeaderData[] = $textToAdd;
        }
    }

Usage:

<solpersons:addToHtmlHead>
    <link rel="stylesheet" type="text/css" href="{f:uri.resource(path:'Styles/default.css')}" />
</solpersons:addToHtmlHead>

<div class="tx-solpersons-pi1">
    <f:render section="main" />
</div>

...or alternatively

<solpersons:addToHtmlHead key="tx_solpersons_pi1_headCSS">
    <link rel="stylesheet" type="text/css" href="{f:uri.resource(path:'Styles/default.css')}" />
</solpersons:addToHtmlHead>

Thanks for reading :)

Best,
Adrian

History

#1 Updated by Adrien Crivelli over 3 years ago

I would suggest rejecting this ticket in favor of FED extension and its numerous ViewHelpers, especially http://fedext.net/fed-viewhelpers/resource/style.html.

#2 Updated by Adrian Föder over 3 years ago

everyone feel free to kick this; it's definately orphanaged and nobody cares. However; I used that in may projects because it's IMHO the ideal, smart, tiny approach to get it achieved.
Unfortunately I myself am not allowed to cancel this item; I think it's the prj leader's task.

Also available in: Atom PDF