Jump to content

Only show own pages


asilentwish
 Share

Recommended Posts

Hello,

I'm new to the forum and was wondering how to do the following:

I have created a role for certain users who are only allowed to edit their own pages. I created a module which list only their pages.

public function viewable(HookEvent $event) {
	    if(!$event->return) return;
	    $page = $event->object;
	    if($this->user->name !== $page->createdUser->name && $page->id != 1 && $page->id != 1046) $event->return = false;
	}

The superuser sees this:

Home
- Page
--Subpage 01
--Subpage 02
--Subpage 03
--Subpage 04
--Subpage 05

The specific user sees this:

Home
- Page
--Subpage 02
--Subpage 05

This works just fine. 

But when I'm logged in as a specific user I still see all the pages in the submenu and can still edit them. I don't want this. 

Is it possible to remove all the other pages and only show the pages that the logged in user created?

Is is also possible to remove them from the search results when I'm logged in with specific role? 

 

Thank you in advance.

Alvina

Link to comment
Share on other sites

Thank you for your replies but that didn't seems to work for me. Here is a screenshot of my problem. 

 

image.thumb.png.e35cec5e3bdbd80d1a017f33da8ee5a2.png 

 

I want the submenu (the part in black) to only show the same pages as the listview (left side). 

When I hover over Structuur I only want to see: 

Home
Vacatures

when i hover over Vacatures I only want to see the two pages seen in the left side 
1070
1069 

Unfortunately I see all pages and can even edit them all. 

Link to comment
Share on other sites

@asilentwish - please take a look at the AdminRestrictBranch module that @bernhard mentions - it takes care of these menus and all sorts of other issues. Obviously it doesn't hide the pages you want, but you'll be able to grab the bits of code you need from that and add it to one of those gists I listed.

But please also read thoroughly through that forum thread - there are issues with what you want to do - what if a parent is hidden, but the user needs access to the children?

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...