inherit
248478
0
Jul 30, 2020 11:38:32 GMT -8
Caligosus
10
August 2017
caligosus
|
Post by Caligosus on Aug 23, 2017 3:32:56 GMT -8
I'm wondering if there is such thing as an if/else operator that can partially match a string or whatever, similar to CSS selectors.
[attribute~=value] [attribute|=value] [attribute^=value] [attribute$=value] [attribute*=value]
I'm making a custom menu for certain pages around my forum using {if $[title] == "Home"}. However, I'm running into a problem with the PM view page. The page title is the PM subject rather than something static... I managed to add permanent text to the beginning of the PM subject that can't be deleted and gets attached to the page title, but now it seems I don't have an operator to work with.
What I'm trying to do is this:
{if $[title] == "Personal Messages" || $[title] == "New Message" || $[title] ^ "[PM]"} {* I inserted the CSS selector ^ as an example of what I would like to do *}
<div class="page-title">M E S S A G E S</div>
<div class="page-menu"> <table class="pm-container" style="border-collapse: collapse !important;"> <tr> <td><a href="/conversations/inbox">Inbox</a></td> <td><a href="/conversations/outbox">Outbox</a></td> <td><a href="/conversations/archive">Archive</a></td> <td><a href="/conversation/new">Create</a></td> </tr> </table> </div>
{/if} I suppose if I have to, I'll find another way to do this... It just seemed like a simple method up until I ran into this problem.
|
|
#eb7100
33409
0
1
Nov 24, 2024 4:27:37 GMT -8
Brian
48,130
November 2004
smashmaster3
|
Post by Brian on Aug 23, 2017 9:42:00 GMT -8
Hi, Caligosus. If statements in templates only support the following comparison operators: == != > < >= <= You may want to familiarize yourself with the $[route.name] variable and its values on each page and compare against it instead as special route names are assigned to most page types on the forum and can be used to uniquely identify what action you're performing. You can get the route name of any page by navigating to that page, pressing F12 to open the browser's console and typing this into the Console tab:
|
|
inherit
248478
0
Jul 30, 2020 11:38:32 GMT -8
Caligosus
10
August 2017
caligosus
|
Post by Caligosus on Aug 23, 2017 11:07:41 GMT -8
Ohh, thank you so much! $[route.name] is exactly what I needed. I've only recently been learning how to work with templates, so I don't know what everything is yet, hah... Thank you again.
|
|