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

XF 1.3 Node Style Options

#1
I have two Styles on my site, a fixed width of 1200px and a fluid layout.

On several of my nodes I have forced a style to remove components I don't want. (Sample) Is there a way from within a style to detect the users selected style? Then I could add this to the width control of the forced style:

Code:
<xen:if {style = 'static'}>
max-width: 1000px;
margin: 0 auto;
box-sizing: border-box;
</xen:if>
 

Brogan

XenForo moderator
Staff member
#3
I'm not sure I understand what it is you are trying to do.

There is no need to detect which style the visitor is using; just add the CSS to EXTRA.css for each style.
 
#4
I'm not sure I understand what it is you are trying to do.

There is no need to detect which style the visitor is using; just add the CSS to EXTRA.css for each style.
Style1: Fixed Max Width, User Selectable, Default
---Style2: Fluid, User Selectable
---Style3: Fixed (Currently), NON User Selectable

Style 3 is utilized for specific nodes. For these nodes I have stripped out much of the 'forum' type content, things like # of posts, RSS links, etc. It is statically set on the nodes with the Force Style option.

Thus if a user visits the site they see a fixed width site. If they view those nodes, they are also a fixed width. If a user registers and changes to the Fluid site, the site is fluid, but those nodes are still a fixed width. I'm trying to make those nodes respect the users width choices.

I've modified the public.css as follows:
Code:
.pageWidth
{
    @property "pageWidth";
    padding-right: 5px;
    padding-left: 5px;
    margin: 0 auto;
    @property "/pageWidth";
   
    <xen:if is="{$visitor.style_id} == 8">
        max-width: 1200px;
        margin: 0 auto;
        box-sizing: border-box;
    </xen:if>
}
However it doesn't appear that the $visitor.style_id variable is in scope when this is processed as it doesn't evaluate True. The same code just dropped into a custom page template does work.
 

Brogan

XenForo moderator
Staff member
#5
OK, that gives a better picture of what it is you're doing.

That conditional statement isn't available in the CSS templates however.
You might be able to do it by editing the templates directly and adding a class using that though.
 
#6
This requires modifying 5 templates but works perfectly! In case anyone else is trying to do this...
  • search_bar
  • moderator_bar
  • logo_block
  • navigation
  • PAGE_CONTAINER
Added the if block:
Code:
<div class="pageWidth {xen:if '{$visitor.style_id} == 8', 'ikesWidth'}">
And added the CSS to EXTRA.css