Fixed Period After Style Property Breaks It

pegasus

Well-known member
I have a style property that sets the names of CSS images, based on the admin's selection (using templates to create the fields, etc). I have had no problems doing that, getting the values saved, validated, and recalled properly.

But when I try to use that in a specific CSS configuration, I encounter a problem:
Code:
.cssClass {
    background-image: url(@myImageFolder/@myImagePrefix@myImageVariant.png);
}
As you can see the image path is constructed using multiple properties.
As far as I know, there's no way to escape out of a property name. Wrapping it in brackets outputs the brackets around the property value.

Particularly, properties like the . character. Even though @myImageVariant exists, the parser sees instead a sub-property @myImageVariant.png which doesn't exist. Because of the dynamic nature of these paths and the number of them, it's also not practical to include the .png as part of the property value. I've considered renaming the files, putting a garbage character like _ before the .png, but again, I'm unaware of a way to escape the property name, so we would still have @myImageVariant_.png

I've tried using {xen:property myImageVariant} directly instead. This causes the template to parse correctly, but if I open the editor again, it's changed back to @myImageVariant, so anyone who edits the template would just get the original problem again.
 
try

Code:
.cssClass {
background-image: url({xen:property myImageFolder}/{xen:property myImagePrefix}{xen:property myImageVariant}.png);
}
 
As I mentioned in my post, this only works the first time and if you remember to manually change it every time after that. When you go back to the editor later, XenForo always changes it back to @syntax.

EDIT: For now I'm using the following temporary solution. I would prefer some way to do it on one line, or by calling a {xen:helper concat} (which does not exist).

Code:
.cssClass {
    <xen:set var="$a">@myImageVariant</xen:set>
    background-image: url(@myImageFolder/@myImagePrefix{$a}.png);
}
 
Fixed now. It won't translate the {xen:property} style to @ if the property tag is followed by something that would make the result be ambiguous.
 
Back
Top Bottom