XF 2.1 How to access style id from template? $xf.style.id does'nt work

Earl

Well-known member
{{ dump($xf) }} shows this:
bDLfVWc.png


{{ dump($xf.style) }} shows this:
ZQ3m27I.png


but {{ dump($xf.style.id) }} shows null:
f3IW1P2.png


I'm confused o_O
 
Solution
Dumping an object in this way isn't always the best way to reveal the methods and properties it has.

The reason this doesn't work is id is actually a protected property (I think that's what the # means, in fact).

But something that is useful here is that it tells you that style is actually a Style object and if you're unsure of what the full class name is you can hover over the word Style. In this case it is XF\Style.

If you take a look at that class, hopefully it will become clear how to access the style ID.
Dumping an object in this way isn't always the best way to reveal the methods and properties it has.

The reason this doesn't work is id is actually a protected property (I think that's what the # means, in fact).

But something that is useful here is that it tells you that style is actually a Style object and if you're unsure of what the full class name is you can hover over the word Style. In this case it is XF\Style.

If you take a look at that class, hopefully it will become clear how to access the style ID.
 
Solution
Dumping an object in this way isn't always the best way to reveal the methods and properties it has.

The reason this doesn't work is id is actually a protected property (I think that's what the # means, in fact).

But something that is useful here is that it tells you that style is actually a Style object and if you're unsure of what the full class name is you can hover over the word Style. In this case it is XF\Style.

If you take a look at that class, hopefully it will become clear how to access the style ID.
Thank you for giving very informative response. I found how to access it with the help of your reply ($xf.style.style_id).
 
Back
Top Bottom