Target TagID from URL inside IF/Else statement

Dcode warner asked on August 21, 2017 18:03

Can I not target the 'Tag ID' of a URL? below is one of the methods I've tried so far:

{% if (CMSContext.CurrentDocument.RelativeURL == "~/blog-(1)/?tagid=381") { #%}
Show this
{% } else { #%}
Show something else
{% } #%}

This just returns the 'else' result on every page. So it's not working.

Correct Answer

Dcode warner answered on August 21, 2017 18:46

@Brenden Kehren. Thank you for you're reply. I modified it to this and it works:

{% if (QueryString.GetValue("tagid") == "381") { |(identity)GlobalAdministrator%}

0 votesVote for this answer Unmark Correct answer

Recent Answers

Brenden Kehren answered on August 21, 2017 18:10 (last edited on August 22, 2017 14:56)

You're referencing the actual URL stored in the database and not the rendered URL with the parameters. SO you might try something like:

if(QueryString.GetValue("tagid") == "381"}

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.