Visualizer Templates: Conditional operations using if/else

Overview 

In this article, we will manipulate a visualizer using conditional statements that will serve as a working sample for template designers. 

Objective

Create a list Visualizer template where the items in the list contain a dynamic redirection (<a HREF=> ) to a document, URL or detail-page depending on which one is available. 

Requirements

  • DNN Evoq Version: 9.+
  • Create a content item with four items correctly associated with content-name(s)
    • Title as single line text
    • LinktoDocument as Document 
    • LintoWebpage as URL
    • Description as multiline text (for item details page) 

Pseudo-code

  • Check if there is a valid linktoDocument
    • If yes, print out link associated with the document
    • If not, check if we have a valid linktowebpage
      • If yes, print out link associated to the page
      • If not, print out contentDetailsUrl for details page. (It will take the user to the details page associated with the content item)

Source code 

<div>
<h2>{{title}}</h2>
<p>
{% if linktoDocument != empty %}
<a href="{{linktoDocument | documents_url}}">{{title}}</a>
{% elseif linktowebpage != empty %}
<a href="{{linktowebpage}}">{{title}}</a>
{% else %}
<a href="{{contentDetailsUrl}}">{{title}}</a>
{% endif %}
</p>
</div>

Related articles 

Content Author

Hamid Waqas

 

Comments

1 comment

  • Avatar
    Craig Bauer

    I found that you need to use null rather than empty.

    {% if linktoDocument != null %}
    0
    Comment actions Permalink

Please sign in to leave a comment.