Pennebaker / craftcms-thearchitect

CraftCMS plugin to generate content models from JSON data.
MIT License
171 stars 9 forks source link

Impossible to invoke a method ("getAllGroups") on a null variable #19

Closed magicspon closed 8 years ago

magicspon commented 8 years ago

Hello,

I've just installed this plugin on the latest version of craft (2.6.2944) and I'm getting the following error when I go to the export tab.

Impossible to invoke a method ("getAllGroups") on a null variable

/craft/plugins/thearchitect/templates/blueprint.twig(302)

{% for group in craft.userGroups.getAllGroups() %}
<tr class="group" data-id="{{ group.id }}" data-name="{{ group }}">
    <th scope="row" class="name">
        <input type="checkbox" id="group{{ group.id }}" class="checkbox" name="groupSelection[]" value="{{ group.id }}"> <label for="group{{ group.id }}">{{ group }}</label>
    </th>
    <td>
        <code>{{ group.handle }}</code>
    </td>
</tr>
{% endfor %}

I have fixed this by wrapping the loop with {% if craft.userGroups|length %} ... {% endif %}

Thanks

magicspon commented 8 years ago

Just submitted a pull request

spAnser commented 8 years ago

Damn craft that function should be availed regardless of if groups exist or not. Maybe it saves memory not having it available? Turns out it is part of Craft Pro License.