Question

Photo of Trey Hendon III

0

External Website Ads Redirect

Has anyone figured out a way to use the External Website Ads and have them redirect to a specific URL rather than the Item Details?

CMS
  • Trey Hendon III

    I've added an attribute to my Website Ads called "Direct URL", but am having a problem with the Lava template.
    Lava I'm using:
    {% if { item | Attribute:'DirectURL' } != empty -%}
    <a href="{{ item | Attribute:'DirectURL' }}">{{ item.Image }}</a>
    {% else %}
    <a href="{{ LinkedPages.DetailPage }}?Item={{ item.Id }}">{{ item.Image }}</a>
    {% endif %}


    I'm getting this error:
    Liquid error: Value cannot be null. Parameter name: input

  • Photo of Rock RMS

    0

    You can't really embed the value in that IF statement like that. You can use the Assign tag to first assign a variable and then use that instead.  For example: 

        {% assign directUrl = item | Attribute:'DirectURL' %}
        {% if directUrl != empty -%}
            <a href="{{ item | Attribute:'DirectURL' }}">{{ item.Image }}</a>
        {% else %}
            <a href="{{ LinkedPages.DetailPage }}?Item={{ item.Id }}">{{ item.Image }}</a>
        {% endif %}    

     

  • Photo of Don Smallman

    0

    Can this be applied to a single Ad image, or does it have to apply to all images on ad rotator?

    • Trey Hendon III

      Hey Don, the way I wrote the extra liquid and attribute, it's per ad. So, it allows me to have a single image in my rotator that isn't a hyperlink.


      I've added two attributes to the Website Ads' Item Attributes: Direct URL [Text] and Not Clickable [Boolean]


      The "Direct URL" Attribute's Lava logic I have in the AdRotator.lava file and the AdList.lava files. The Not Clickable Attribute I only use for the rotator.


      Here's my final Lava for the Ad Rotator file:


          {% assign notClickable = item | Attribute:&#39;NotClickable&#39; %}
      {% if notClickable == &#39;Yes&#39; %}
      {{ item.Image }}
      {% else %}
      {% assign directUrl = item | Attribute:&#39;DirectURL&#39; %}
      {% if directUrl != empty -%}
      &lt;a class=&quot;announcement-link&quot; href=&quot;{{ item | Attribute:&#39;DirectURL&#39; }}&quot;&gt;{{ item.Image }}&lt;/a&gt;
      {% else %}
      &lt;a class=&quot;announcement-link&quot; href=&quot;{{ LinkedPages.DetailPage }}?Item={{ item.Id }}&quot;&gt;{{ item.Image }}&lt;/a&gt;
      {% endif %}
      {% endif %}