Skip to content

Commit

Permalink
Setup ability for user to add entries in sections they have access to
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronbushnell committed Feb 22, 2019
1 parent aff2efe commit 73f77da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/services/AuthenticationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function isUserInEntry()
if (
Craft::$app->request->getSegment(1) === "entries" &&
Craft::$app->request->getSegment(2) !== "" &&
Craft::$app->request->getSegment(3) !== ""
Craft::$app->request->getSegment(3) !== "new"
) {
return true;
}
Expand Down
13 changes: 13 additions & 0 deletions src/templates/index.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@

{% set sectionGroup = craft.app.sections.editableSections | group('type') %}

{% block actionButton %}
{%
if craft.isolate.isUserIsolated(currentUser.id) and
craft.app.request.getSegment(3)
%}
{% set section = craft.app.sections.getSectionByHandle(craft.app.request.getSegment(3)) %}

{% if currentUser.can("createEntries:" ~ section.uid) %}
<a href="{{ url('entries/' ~ section.handle ~ '/new') }}" class="btn submit add icon">New entry</a>
{% endif %}
{% endif %}
{% endblock %}

{% block sidebar %}
<nav>
<ul>
Expand Down

0 comments on commit 73f77da

Please sign in to comment.