maikschneider / bw_icons

TYPO3 extensions that provides an icon picker for TCA and RTE.
GNU General Public License v2.0
1 stars 2 forks source link

No icon in frontend #42

Closed martin-git-kristensen closed 10 months ago

martin-git-kristensen commented 10 months ago

My setup is typo3 11.5.33 with php 8.2.13 and bw_icons 2.1.7

In typo3 backend everything is fine - I can choose the icons for ex a header element - but when I use in my fluid template for ex. header.html nothing shows up in frontend. When I debug: {data}</f:debug> there is nothing in {data} even if the header element has a icon in the backend and also in the tt_content database there is a field called tx_bwicons_icon and for the element there is a value: EXT:fontawesome/Resources/Public/Images/Icons/Fontawesome/algolia.svg How can I get the icon to show up in the frontend?

maikschneider commented 10 months ago

Hey,

When I debug: {data}</f:debug> there is nothing in {data}

Is the whole data array empty? Please check again with <f:debug>{_all}</f:debug>. Make sure it really is the correct element template you are debugging.

but when I use

As soon as you have the value (EXT: fontawesome/...svg) in the frontend you should use the f:uri.resource-ViewHelper. The f:image ViewHelper is not suitable anymore for extension assets.

maikschneider commented 10 months ago

Try to add the debug statement into the Layout of your fluid_styled_content element. Maybe you are trying to access the data from a partial: Fluid styled content does not always pass all variables with arguments="{_all}", but only needed data, especially for the header partials.

martin-git-kristensen commented 10 months ago

The whole data array is empty in the partial Header.html - and in the Layout Default.html the {data.tx_bwicons_icon}</f:debug> returns the right value. Then I need the f:uri.resource in the partial - will it works there when the data array is empty in partial?

maikschneider commented 10 months ago

You have to check the whole template inclusion path:

The entry point is your Templates/Header.html, Templates/Textmedia.html,... All of these use the Layouts/Default.html Layout. This layout file renders the Partials/Header/All.html partial with arguments="{_all}" - fine so far. However, this partials renders Partials/Header/Header.html with only a proportion of variables:

<f:render partial="Header/Header" arguments="{
                header: data.header,
                layout: data.header_layout,
                positionClass: '{f:if(condition: data.header_position, then: \'ce-headline-{data.header_position}\')}',
                link: data.header_link,
                default: settings.defaultHeaderType}" />

You could override this file and add icon: data.tx_bwicons_icon to the arguments. Then you can access the data via icon. Good luck! :)

martin-git-kristensen commented 10 months ago

So very NICE - I have learned something today - this works and now I just have to puzzle with the f:uri.image or what img src to retrieve the {icon} - HAPPY NEWYEAR and thanks for your great help :-)