Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Linguica Posted March 10, 2017 Posted March 10, 2017 I wanted to add in a thing to make every user see quotes of themselves in a different color so it was more immediately noticeable. The obvious way to do this was to add a customized CSS rule to every user's CSS that would be processed by the templating engine. However, it doesn't seem that the available shortcuts can be inserted into a template by their actual variable, just as part of the HTML logic if-else or foreach or whatever. Trying to insert {member.member_id} resulted in that literal text being inserted, and trying {$member.member_id} gave an error. I managed to get around this by immediately assigning the shortcut variable I cared about to a *second* variable inside of a pointless logic check and then inserting that one, which worked well enough: {{if member.member_id}} [data-ipsquote-userid="{{if $id = member.member_id}}{$id}{{endif}}"]{ background: #173747; } {{endif}} This seems pretty messy and hacky to me though, and I am just wondering if I overlooked something and there is a more straightforward way of doing this.
BomAle Posted March 10, 2017 Posted March 10, 2017 check template plugin guide... {member="member_id"}
Linguica Posted March 10, 2017 Author Posted March 10, 2017 Doesn't work. Which is kind of funny, since it clearly *does* work if you use a hacky way of accessing it... but now I am wondering if I am subtly breaking something by doing this.
Linguica Posted March 10, 2017 Author Posted March 10, 2017 And a quick test shows that my suspicion was correct: if you do that hack to put a member-specific variable into a CSS file, and then the user logs out, the guest user will still see the original user's posts highlighted for as long as the CSS is locally cached. I guess I'll just inline it in the HTML head: {{if member.member_id}}<style>[data-ipsquote-userid="{member="member_id"}"]{ background: #173747; }</style>{{endif}} I guess this goes to show that just because you can do something doesn't mean that you should
Recommended Posts
Archived
This topic is now archived and is closed to further replies.