• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

which of these conditionals is correctly written?

edprush

Platinum Member
<if condition="$forum[link] != ''">target="_blank"</if>

or

<if condition="$forum[link] != ''">target="_blank"</if>

The only difference is the [link] vs ['link']

Thanks.
 
Originally posted by: edprush
<if condition="$forum[link] != ''">target="_blank"</if>

or

<if condition="$forum[link] != ''">target="_blank"</if>

The only difference is the [link] vs ['link']

Thanks.


No, I'm thinking both lines of code are identical 🙂 Now, you may have meant one to be different than the other.......
 
Sorry. Here's try number 2:


Which of these conditionals is correctly written?

<if condition="$forum[link] != ''">target="_blank"</if>

or

<if condition="$forum['link'] != ''">target="_blank"</if>

The only difference is the [link] vs ['link']

Thanks.
 
I've always used ['link'].


EDIT:

Originally posted by: troytime
wouldn't it depend on the language?

if its php, $forum['link']

your code doesn't look like php though

^ He's right if it's PHP. Are you just wording your conditional instead of putting it in code?
 
Originally posted by: ruijorge
The one that works 😛.

in this case, they'd both work - unless there was a constant named link, which would cause unexpected behavior for the unquoted array key
 
In most languages, you'll want to use $forum['link'] because it's a named key. $forum[link] MIGHT work, but it's bad practice to do so, and as troytime mentioned, if there's a constant named link it'll cause some strange behavior you'll spend hours trying to find again, when you could simply do it right the first time.
 
Back
Top