3

Spinning wheels..

I need to separate pages into permission groups. I am using Structure. And I have Entry Access.

I'm not sure how to integrate this. I've been through the documentation of Entry Access and Structure while I have seen something close maybe I'm missing the clue to solving this...

All of the website content is all through Structure minus the /index and /event page.

All of the pages that are within Structure use 1 template /structure/page which comes from one channel {exp:channel:entries="page"} to populate the site's content. To possibly complicate matters for a front-end type of dashboard the site also pulling that channel again using {exp:channel:form channel="page"}

The issue is that I need to have 12 different permission groups.
Each needing access to a different area (page) within the /structure/page template and channel.

For example: /about using the /structure/page template will need to be accessed by permission group A

while /gallery also using the /structure/page template and channel will need to be accessed by permission group B and so on and so forth where some pages will need to have multiple permission groups allowed...

A couple of questions however:
Is there currently any way to do this with Structure as we have the site currently setup? 1 channel feeding 1 structure/page template.

And if so, any suggestions to nudge me in the right direction for setting up these permissions??

Thanks in advance!

Here's what the front-end template currently has. It works well but, without permission control.

{exp:channel:form channel="page" entry_id="{segment_3}" id="publishForm" return=""}

  </div>
</div>
<div class="col-lg-12">

  <div class="form-element-wrapper">
    <label for="title">Title</label>
    <input class="form-control" type="text" name="title" id="title" value="{title}" disabled="true">
  </div>

  <div class="form-element-wrapper" id="images-container">
    <label for="">Image Carousel</label>
    <div class="clear"></div>
    {field:images}
  </div>

  <div class="form-element-wrapper">
    <label for="about">About</label>
    {field:about}
  </div>

  <div class="form-element-wrapper">
    <label for="body">Body</label>
    {field:body}
  </div>

  <div class="form-element-wrapper" id="faq-container">
    <label for="">FAQ</label>
    <div class="clear"></div>
    {field:faq}
  </div>

  <div class="form-element-wrapper" id="external-links-container">
    <label for="">External Links</label>
    <div class="clear"></div>
    {field:external_links}
  </div>

  <div class="form-element-wrapper" id="documents-container">
    <label for="">Documents</label>
    <div class="clear"></div>
    {field:documents}
  </div>

  <div class="form-element-wrapper" id="message-container">
    <label for="message">Message</label>
    {field:message}
  </div>

  <div class="form-element-wrapper" id="mission-container">
    <label for="mission">Mission</label>
    {field:mission}
  </div>


  <input id="submit-form" type="submit" name="submit" value="Update and Finish" class="fin btn btn-primary btn-lg pull-right" style="margin:0 2% 2% 0;">
  <input id="submit-form" type="submit" name="submit" value="Update" class="upd btn btn-primary btn-lg pull-right" style="margin:0 2% 2% 0;">

</div>
{/exp:channel:form}


{if:else}
<div class="well well-lg"> 
<button id="page_select_submit" type="submit" class="btn btn-primary pull-right">Go...</button>
<select name="structure_parent_id" class="chosen-select">
<option value="0" selected="selected">Choose a Page...</option>

<!--  GROUP A  -->
<option value="100"> Page1</option>
<option value="200">-- Page2</option>
<option value="300">-- Page3</option>


<!--  GROUP B  -->
<option value="400"> Page4</option>
<option value="500">-- Page5</option>
<option value="600">-- Page6</option>


<!--  GROUP C  -->
<option value="700"> Page7</option>
<option value="800">-- Page8</option>
<option value="900">-- Page9</option>

<!--  GROUP D  -->
<option value="100"> Page1</option>
<option value="500">-- Page5</option>
<option value="1000">-- Page10</option>



</select> 

</div>

{/if}

<script>
$(document).on('mouseenter', '.fin',  function(){
 $('[name=return_url], [name=return], [name=RET]').val('embeds/success');
});

$(document).on('mouseenter', '.upd',  function(){
 $('[name=return_url], [name=return]').val('embeds/success/{sement_3}');
});
</script>

On the option dropdown. I would like to only show the pages/ option vaulues that are relevant to that particular permission group to edit.

  • You seem to have two kinds of content; About and Gallery. Why restrict access to either? Why two member groups? What does "access" by these groups mean? Are we talking CP access or front end access? If CP access, what permissions? Why only one channel? Why only one template? Which users can create content? Which can only view content? I suggest you update your question with more details covering the content/group/create/view relationships you need and why you need them exactly like that so that participants here can help some more. – John de Beer Jul 26 '14 at 4:41
  • You're wanting to control access to the entry in the CP or front-end? – Stephen Callender Jul 30 '14 at 21:45
  • 1
    I'm wanting users to log into a dashboard area, that was created using Channel Form (SafeCracker) and when they log in, they are only shown pages from structure that they have permission to edit. – Cedric Jul 30 '14 at 22:56
3
+50

I did this exact same thing all natively with the exception of structure a few months ago. The challenge was to provide member groups access to different information on the same template with the added challenge of each member group having a state affiliation and union affiliation that they belonged to.

The most difficult part was a file system (think dropboxish) that showed particular documents according to state location and union access.

I controlled the file from the backend using grid which used searchable checkboxes to specify member and union types. Then used EE template embeds to work the magic.

My embed template:

{exp:member:custom_profile_data}

{if State == "{embed:state_name}"}

{exp:channel:entries channel="documents" dynamic="yes" limit="1" disable="categories|pagination"}

    {folders}

        {if folders:state_access == "{embed:state_name}" AND folders:union_access == "All Unions"}

            {sn_directory}

        {/if}

    {/folders}

{/exp:channel:entries}

{/if}

{/exp:member:custom_profile_data}

We need to include the {exp:member:custom_profile_data} in the embed because it is parsed AFTER the page is loaded. The union search could also be an embed variable if you wanted to loop out content on your template.

{sn_directory} is a snippet I use to cache out the directory code which looks like

<ul>
    {folders:document_file}
        <li>
            <a href="{folders:document_file:document_file}">
                <i class="icon icon-file"></i> {folders:document_file:title}
            </a>
        </li>
    {/folders:document_file}
</ul>

In my template I pull the information in like so:

{exp:member:custom_profile_data}

    {if State == "Alabama"}
        {embed="directory/index" state_name="Alabama"}
    {/if}
{/exp:member:custom_profile_data}

Notice we're opening the custom profile data tag again. if State == represents the member's state field and the state_name references the embed variable.

After this stage you could write something to loop that out 50 times or copy and paste it 50 times, doesn't really matter in my case but could in yours.

Either way, this works, it's fast, it's reliable and easy to maintain with zero add-ons.

Check out embed variables at http://ellislab.com/expressionengine/user-guide/templates/embedding.html

| improve this answer | |
  • 1
    Thank you for your answer! This {exp:member:custom_profile_data} seems to be exactly what I needed...permissions are now working for each member group.. Now I'm wondering-- Is there a way that I can add permissions to a specific page rather than give the member group the permission so in the future any changes to permissions would not have to be hard-coded as I have listed below? – Cedric Jul 31 '14 at 21:21
  • Awesome! So glad that works for you. If you could, please mark this as answered if it suits you. As for a specific page, I'm not sure about that with structure but you can limit channels to members so maybe that would work for you. – thatgibbyguy Aug 1 '14 at 17:39
  • 1
    So, I would have to do a restructure basically since I only have one channel? And do you know of anyway to control permissions that would be less hard-coded for lack of a better term? Thanks again for the awesome answer. – Cedric Aug 1 '14 at 17:46
  • 1
    Would it be best to create a new question to answer that particular one? – Cedric Aug 1 '14 at 17:47
  • It's a weird way you're phrasing the question because on one hand, what I provided solves the issue of making it easy to post things based on member group and member data. On the other, it doesn't involve structure, so it doesn't answer that part of your question. I would say that because structure is an add-on perhaps look through their docs if you want to do it that way. However, I would recommend just setting member access via your template code. – thatgibbyguy Aug 2 '14 at 18:13
4

You need to create a channel field into that channel and in channel entry, you need to assign that user group type who can access the page.

for eg:

Suppose you have a channel (named as "XYZ") and add a new channel field (as 'group_permission'). This channel field can be drop down and you can add group listing in drop down (as group A, group B)

Now Go to this channel entries and you can see this new field 'group_permission' in these all entries. Now you can assign a group type (group A or group B) in channel entry.

Then you need to add following code to check the permission for entry into template as below :

{exp:channel:entries channel="XYZ}
    {if group_permission == 'group A'}

        //action you want to perform or redirect on other page 

    {/if}

    {if group_permission == 'group B'}

        //action you want to perform or redirect on other page 

    {/if}

     // your code...

 {/exp:channel:entries}

So you need to use your code like this.

| improve this answer | |
1

I suggest you take a look at HooBlong, a module that allows members to belong to more than one group for front-end access control. More details can be found at https://www.debeer.com/index.php/debeer/expressionengine_meet_multiple_memberships. There are some examples that could fit your needs at https://www.debeer.com/index.php/blogs

| improve this answer | |
  • 1
    Hi John, so does HooBlong allow permissions to be implemented using only 1 channel or would HooBlong still need to make use of multiple channels? – Cedric Jul 25 '14 at 18:50
  • 1
    For example: /about using the /structure/page template will need to be accessed by permission group A while /gallery also using the /structure/page template and channel will need to be accessed by permission group B and so on and so forth where some pages will need to have multiple permission groups allowed... – Cedric Jul 25 '14 at 18:52
  • 2
    It's not that I must have one channel, it's that the current site as is.. is using Structure and all content goes through structure into one Structure Page coming from one channel. I believe this was done because the channel fields for each page is exactly the same. To give more about the site-- It's an entity that has 20-30 departments each department with a content administrator for the content publishers for their respective departments. The content in terms of field groups are the same on each page. about, body, mission statment, vision statement, doc widget area, contact info, etc. – Cedric Jul 28 '14 at 18:02
  • 1
    Cedric - slowly I begin to understand. With that many departments all publishing through the same channel, how do you know one kind of entry from another? If there is to be different access control for different users, there must be some way to know the difference between entries. Then all we need to know is how many diffrent kinds of users, and map them against the kinds of entries to which they have access. Once we can see that map, we can design an access/member management strategy. – John de Beer Jul 29 '14 at 7:55
  • 1
    So, if I'm understanding correctly... It seems as though the content needs to broken up into multiple channels per department correct? Then, from there the permissions would be able to be implemented? – Cedric Jul 29 '14 at 19:01
1

After much fuss.....(see below)

{if:else}
<div class="well well-lg"> 
<button id="page_select_submit" type="submit" class="btn btn-primary pull-right">Go...</button>
<select name="structure_parent_id" class="chosen-select">
<option value="0" selected="selected">Choose a Page...</option>

{exp:member:custom_profile_data}

{if member_group == "1"}

<!--  GROUP A  -->
<option value="100"> Page1</option>
<option value="200">-- Page2</option>
<option value="300">-- Page3</option>

{/if}

{if member_group == "2" }

<!--  GROUP B  -->
<option value="400"> Page4</option>
<option value="500">-- Page5</option>
<option value="600">-- Page6</option>

{/if}

{if member_group == "3" }

<!--  GROUP C  -->
<option value="700"> Page7</option>
<option value="800">-- Page8</option>
<option value="900">-- Page9</option>

{/if}

and for pages that need multiple groups to access them:

{if member_group == "4" OR member_group =="5" OR member_group == "6"}

<!--  GROUP D  -->
<option value="100"> Page1</option>
<option value="500">-- Page5</option>
<option value="1000">-- Page10</option>

{/if}

</div>

{/exp:member:custom_profile_data}

{/if}

NOW, the question is.. if in the future a member group needed access to a different page. How would that happen without having to hardcode that into the template as performed above?

I do have the Entry Access addon. That seems like it could help to solve this situation but the documentation seems limited.

| improve this answer | |
  • This is what I meant on my previous response to you as far as how to manage it in the template. As for automatically extending it based upon new member groups I would suggest adding a channel or channel field that corresponds to your member groups, and loops out accordingly. – thatgibbyguy Aug 2 '14 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.