Jump to content

Process module with certain permission not showing up


owzim
 Share

Recommended Posts

Hi,

I have a Process module, with a permission 'my-permission'. The user 'user1' has role 'editor' which then has 'my-permission'. The process page under admin is still only showing up for the superuser. Anything else I missed? On 2.7.2.

Thanks.

Link to comment
Share on other sites

Ha...I had the exact same question :-). A process module I am working on is not appearing in the menu, even when I remove a permissions requirement. It works practically the same as my ProcessBlog module, the only difference being that Blog shows up in the Admin menu for users with role 'blog' but in the case of this other module, similar to your case, the module doesn't show up in the Admin menu!  :(

Link to comment
Share on other sites

In my case there are no typos.

If I change the parent of the process module to be 'setup', it shows up under setup menu. If I change its parent back to 'admin', it doesn't appear. Totally confounded by this one. I've cleared cache and all...

Link to comment
Share on other sites

Got to the bottom of this (I think).

  • Let's say I have a module called ProcessMyModule that has a page called myModulePage that uses the template admin and has the parent admin. That module will display just fine in the admin menu and be visible to users with the permission attached to ProcessMyModule
  • If I add a child page to the page myModulePage, say, myModulePageChild, that uses a template abc,  my ProcessMyModule will disappear from the admin menu. The only way to get it back is to (i) enable 'view and edit access' in the template 'abc' [the Access Tab], and (ii) ensure that 'abc' has a template file. 

So, in my case, the reasons why my ProcessModule was not visible in the admin menu is because its admin page has child pages and those child pages had a template without a template file + without 'view-edit' access enabled.The same thing happens with ProcessMenuBuilder since its admin page has child pages. In the case of ProcessBlog though, its page has no child pages, hence works fine. 

Link to comment
Share on other sites

Thanks @kongondo that helped. There were child pages without template files. I added those. But I had to reinstall the process module to show up again as an admin page.

I think this is very unintuitive and odd behavior isn't it? Should the be an issue on GitHub?

Link to comment
Share on other sites

I see. Still. I stumbled upon this issue many times in other contexts. Pages did not show up, where not viewable or something similar, because some other page in some relation to it had no template file. In processwire we often use pages if not more for data storage and not to be an actual frontend page, so there should be a and additional flag the the page class or something which helps with that.

Link to comment
Share on other sites

There's this part in AdminThemeDefaultHelpers.php that I'd call a likely suspect for the missing template file issue.

	public function renderTopNavItem(Page $p, $level = 0) {
	
		$isSuperuser = $this->wire('user')->isSuperuser();
		$showItem = $isSuperuser;
		$children = $p->numChildren && !$level ? $p->children("check_access=0") : array();
		$numChildren = count($children); 
		$out = '';
	
		if(!$showItem) { 
			$checkPages = $numChildren ? $children : array($p); 
			foreach($checkPages as $child) {
				if($child->viewable()) {
					$showItem = true;
					break;
				}
			}
		}
		
		if(!$showItem) return '';

No clue if this is by design or if viewable is simply the wrong check at this point. I guess the correct thing would be to check the current page's permission (through the module info's permission field if present like it does further down when genererating child page entries), and the loop above was meant to hide items without children from the top navigation (I'm not deep enough into these parts of PW to judge if that is needed).

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...