Jump to content

Passing an IPS "shortcut" variable to a template / CSS


Recommended Posts

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;

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.

Link to comment
Share on other sites

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 :whistle:

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...