XF 2.1 Grab property from specific style in templates

Nulumia

Well-known member
I feel like I'm missing something obvious here :unsure:, though similar threads cover grabbing property values from the user's currently selected style.

Is it possible to do so from a specific style ID, for example the default style, from within templates?
 
There's a few features where I'd like to show and compare values set in the default style vs the style currently being used, and use fallbacks for things like logo, favicon and Opengraph image. I can do the conditionals in templates, but can't think of a way to grab them without PHP.
 
There's no way to achieve that from within the templates. You shouldn't need fallbacks though, as style property values are inherited from the parent unless specifically modified in the child.
 
There's no way to achieve that from within the templates. You shouldn't need fallbacks though, as style property values are inherited from the parent unless specifically modified in the child.
Bummer :-(. This is a case though where some of the styles would not be children to pull inheritance, so I was trying to cross-link. Looks like PHP is the way then..

Thanks
 
Bit of tinkering but think this should do it:

HTML:
<xf:set var="$styles" value="{{ $xf.app.em.getRepository('XF:Style').getSelectableStyles() }}" />
<xf:set var="$targetStyleId" value="{{ $xf.options.defaultStyleId }}" /><!-- or some other style ID -->

Current style logo URL: {{ property('publicLogoUrl') }}<br>
Target style logo URL: {$styles.{$targetStyleId}.properties.publicLogoUrl}<br>

I started doing a fallback which would pull the value from the target style's parent if the needed property was inherited, but forgot that these are available in the array whether inherited or not :LOL:
 
Top Bottom