<p>That message is telling you that <code>gatewayHandle</code> can't be accessed from <code>video</code>, because <code>video</code> is <code>NULL</code>. You're expecting the videos field to always contain an object, but in this case it is not.</p>

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

<pre><code>{% set video = entries.video %}

{% if video %}

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

{% endif %}
</code></pre>

CC BY-SA 3.0
2015-02-03T22:24:58.397Z
wouldn't it be: `{% set video = entries.video.first %}`?
Marion Newlevant
CC BY-SA 3.0
2015-02-03T23:41:02.557Z
Could be, that's probably why it's returning `NULL`. I didn't think much about his data structure, just simply telling him what that error meant, and how to protect against it.
Lindsey D
CC BY-SA 3.0
2015-02-02T22:40:53.580Z
2015-02-02T22:40:53.580Z
Lindsey D
<p>I am getting this error returned whilst in Debug mode:</p>

<blockquote>
  <p>Template Error</p>
  
  <p>Impossible to access an attribute ("gatewayHandle") on a NULL variable ("")</p>
</blockquote>

<p>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.</p>

<p>I have attached the relevant page code:</p>

<pre><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;
</code></pre>

<p>Any help would be appreciated.</p>

CC BY-SA 3.0
2015-02-02T22:28:30.773Z
Hi Daryl, looks like you accidentally posted this in the "Meta" section... I'll go ahead and move it back to the main Stack Exchange site for you.
Lindsey D
<templating><plugin-duktvideos>
"Impossible to access an attribute on a NULL variable"
# "Impossible to access an attribute on a NULL variable"

(Asked by: username_0 on 2015-02-02)

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' %}
        
    {% else %}
        
    {% endif %}

{% else %}

{# Entry link #}



Any help would be appreciated.

**Tags:** templating, plugin-duktvideos

> **Comments:**
> **username_1**: Hi Daryl, looks like you accidentally posted this in the "Meta" section... I'll go ahead and move it back to the main Stack Exchange site for you.  

---

## 1 answers

### Answer by username_1 on 2015-02-02. Score: 2

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 %}

> **Comments:**
> **username_2**: wouldn't it be: `{% set video = entries.video.first %}`?  
> **username_1**: Could be, that's probably why it's returning `NULL`. I didn't think much about his data structure, just simply telling him what that error meant, and how to protect against it.  

---

