Can I use isEditable() on a global? I have a headline global.

I am trying to see if headline is editable by using this code block, but it is not working.

Can I use isEditable() with my headline global?

{% if headline.isEditable() %}
    &lt;div class="admin-edit-button-wrapper"&gt;
        &lt;a href="{{ headline.cpEditUrl }}" class="admin-edit-button"&gt;Edit Headline&lt;/a&gt;
    &lt;/div&gt;
{% endif %}
No, the isEditable property isn't supported for Global Sets.

The confusing thing is that the GlobalSetModel class does actually have an isEditable property, however it will always return false. The reason is that this property is inherited from the BaseElementModel class, where it will return false unless the element type overrides it to (potentially) return something else. An example of the latter is the EntryModel class, which also inherits BaseElementModel but overrides  isEditable to test if the current user is allowed to edit the entry.

It'd be interesting to hear P&amp;T's reasoning for not "enabling" isEditable for Global Sets, although to be honest – needing to give users the ability to edit global variables from the frontend sounds like an edge case at best, and probably not a very good idea.

On that note, my best advice for a workaround would be to simply use a Single instead of a Global Set.

However, if you need/want to use a Global Set, you can easily work around the issue by creating a custom plugin exposing a isGlobalSetEditable template variable method. Something like this should work:

public function isGlobalSetEditable(GlobalSetModel $globalSet)
{
    return craft()-&gt;userSession-&gt;checkPermission('editGlobalSet:'.$globalSet-&gt;id);
}


In your template, you could then do something like this:

{% if craft.myPlugin.isGlobalSetEditable(headline) %}
    &lt;a href="{{ headline.cpEditUrl }}"&gt;Edit me&lt;/a&gt;
{% endif %}


If you're not familiar with plugin development, I'd advice you to check out the official docs on the subject, and to download the excellent Business Logic Plugin as a starting point – it even has a Variable class where the above isGlobalSetEditable method could be dropped right in.