• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 2.0 "if" statements and options in .less

BassMan

Well-known member
#1
Hi,

are "if" statements allowed in .less files?

Example:
<xf:if is="$xf.options.test">


What about this:
CSS:
.test {
    font-size: {$xf.options.test}px;
}
 

BassMan

Well-known member
#4
Now I have:
CSS:
.test {
    font-size: @xf-test;
}
But the font size does not change. :(


EDIT: somethings not right. I've completely removed that property, but it still shows font-size in browser inspector.
 

BassMan

Well-known member
#5
Why is that so:

I set this property like this:
1505855580458.png

And the icon size in selected size.


Then I change the value to this:
1505855624932.png

The size of icon stays the same, so 50px.

What am I doing wrong? Why is it not changing?
 

BassMan

Well-known member
#7
Thought of that too, because I've made same add-on from scratch with different ID's and sometimes it works and sometimes it doesn't.

But I'm using Cloudflare for all my other XF1 forums with no problems. Can you please advise what to do next, @Chris D ? Currently I need Cloudflare.
 

BassMan

Well-known member
#8
Now I've disabled CloudFlare cache and after that also temporarily deactivated it for my domain, but it's still ignoring changes as described above.
 

BassMan

Well-known member
#9
After 3 days I've figure it out... doh...:eek:o_O:censored:

If I change value in master style the change does not work. When you edit default style value it works like it shoud. I wasn't aware of that, because in XF1 I've just changed value in master style and the effect was visible at once.

The question is: what do I need to do to change the value in master style if I just decide to change it? Let's say I set font size to 30, then I want it to be 20 by default in master style.
 

Chris D

XenForo developer
Staff member
#10
Well there's no reason why updating the master value wouldn't take effect. The only reason would be if it's modified in a child style. There should be no behaviour change here from XF1.
 

BassMan

Well-known member
#11
I understand, but this is how it works on my side. When I edit value in style properties in master style there is no effect. After choosing default style and change the value effect is visible immediately.

I've just test it once again after your post.
 

Chris D

XenForo developer
Staff member
#12
Are you reverting the value in the default style before attempting to update it in the Master style? Please detail your exact steps.
 

BassMan

Well-known member
#13
In default style everything is reverted. For a few days I was "playing" only with master style, didn't even change to default style in style properties.

When I've created a style property the value I set it works. But after that I want to change that value. Change it, but no effect. Now, 20 minutes ago I change the style properties to default style and change it. It works like it should. That's why I'm confused.
 

Chris D

XenForo developer
Staff member
#14
Start again with a new style property. Write down every step you take including whether it was done in the master style, default style, which add-on is selected (in case of the master style).

We need to figure out if it is reproducible. If it is, then it could be a bug.
 

BassMan

Well-known member
#15
@Chris D
I've created a test add-on and it works exactly as I stated before. Steps are described below.

This is the only enabled add-on on that board.


1. Created a style property for icon size in TEST style properties category:

test_1.png


2. Created 2 templates with test code:

test_2.png


3. Created a template modification to show the test code below forum title on forum_list:

test_3.png


4. It shows like this:

test_4.png


5. Changed value for icon size in master style, saved and no effect:

test_5.png



6. Revert back to 20px icon size in master style, then changed value for icon size in default style, saved:

test_6.png


7. Result:

test_7.png
 
Last edited:

Steve F

Well-known member
#17
@Chris D
I've created a test add-on and it works exactly as I stated before. Steps are described below.

This is the only enabled add-on on that board.


1. Created a style property for icon size in TEST style properties category:

View attachment 158302


2. Created 2 templates with test code:

View attachment 158303


3. Created a template modification to show the test code below forum title on forum_list:

View attachment 158304


4. It shows like this:

View attachment 158305


5. Changed value for icon size in master style, saved and no effect:

View attachment 158306



6. Revert back to 20px icon size in master style, then changed value for icon size in default style, saved:

View attachment 158307


7. Result:

View attachment 158308
Curious, at step 5 when you change the value in the master style to 50px what does it show in the default style?
 

BassMan

Well-known member
#18
Good question, @Steve F.

I changed value to 50px in master style. Nothing changed in frontend. But when I change style properties to default style is looks like this:

1505909782374.png

Of course still no effect. I click Save button now in default style and no effect. Revert value in master style, changed value in default style and effect is visible.
 

BassMan

Well-known member
#20
Probably not exactly what you want to hear but I can't reproduce this with the steps provided.
Hm, you lost me here... I've done several times that procedure, everytime it was the same.

So, what it could be? Could be server side? Sorry, I don't know where else to dig.