"Impossible to access an attribute on a NULL variable" I am getting this error returned whilst in Debug mode:


  Template Error
  
  Impossible to access an attribute ("gatewayHandle") on a NULL variable ("")


Not sure why this is getting flagged up. It is a variable which is accessed through the Dukt Video plugin? Seems to work when not in debug mode, but I am getting slow initial response times when loading, not sure if this is related to that issue.

I have attached the relevant page code:

{# Video Link :: if entry is of video type #}

{% if entries.section == "Videos" %}

    {% set video = entries.video %}

    {% if video.gatewayHandle == 'youtube' %}
        &lt;a
            data-target="flare"
            href="http://youtu.be/{{ video.id }}"
        &gt;
    {% else %}
        &lt;a
            data-target="flare"
            href="http://vimeo.com/{{ video.id }}"
        &gt;
    {% endif %}

{% else %}

{# Entry link #}

&lt;a href="{{ entries.url }}"&gt;


Any help would be appreciated.
That message is telling you that gatewayHandle can't be accessed from video, because video is NULL. You're expecting the videos field to always contain an object, but in this case it is not.

I would suggest that you ensure that video actually contains a value before you attempt to reference one of its properties...

{% set video = entries.video %}

{% if video %}

    {% if video.gatewayHandle == 'youtube' %}
        ...
    {% endif %}

{% endif %}