Jump to content

Page list tree, make branches invisible


Soma
 Share

Recommended Posts

I have a setup where I use a simple module to define editable page(s) for users via a page reference in the user template.

The module has hooks after into Page::editable and Page::addable to then check for pages that are editable. This works fine so far.

But how would it be possible to just show the editable pages in the tree? So other branches are not visible?

I tried with a hook after Page::listable , then if it's the root node "/", it returns true. But the branches are still all listed. When I clik on one he has no access, it throw the exception.

So is there a way I don't see, am I missing something?

Link to comment
Share on other sites

Not that it's much help, but wouldn't a better way be to leave the tree in-tact and instead just remove the Edit link for any page they can't edit? Perhaps somehow highlighting the pages they can edit?

The only reason I mention that is because if you forget to give them access to the parent page of the one you want them to be able to edit then they won't be able to get to that page.

I'm very interested in this by the way if you're creating a module from it? ;)

Link to comment
Share on other sites

Not that it's much help, but wouldn't a better way be to leave the tree in-tact and instead just remove the Edit link for any page they can't edit? Perhaps somehow highlighting the pages they can edit?

That's what I got already. I add parent pages/branch they can edit to the user. It then is like a workspace. Other branches/pages then just don't show the edit/new actions, only view.

The only reason I mention that is because if you forget to give them access to the parent page of the one you want them to be able to edit then they won't be able to get to that page.

Again it's like workspaces for language trees and other branches/sections, so I'm not defining it per page, but it can do it. So this is not an issue much.

I'm very interested in this by the way if you're creating a module from it? ;)

I'm not willing to release it as an official module. It's too simple and something I still think should be possible with PW out of the box.

It's too specific, depends on setups like the roles etc.. so it would require much more to make it work well as a plug in and ready to go module. And since I'm not sure what PW brings in the future, I tend to not go so far and leave it as a simple "modifiy to my needs" hook module.

But I posted the code example in the forum two times already. Here for example http://processwire.com/talk/index.php/topic,524.0.html

Link to comment
Share on other sites

But how would it be possible to just show the editable pages in the tree? So other branches are not visible?

Currently all 'viewable' branches are shown. So if you don't want a branch to appear, then you'd want to change the template it's using to be not-viewable by the user, via their role(s). You'd also want to set non-viewable pages to "not appear in listings" in the template's access settings.

Not sure if that's what you are after, but just wanted to mention it as the PageList tree is supposed to be consistent with the users' view access, not edit access. With access being defined at the template level, I don't think we'd want to have it exclude non-editable pages because it would very likely prevent the user from being able to navigate to the pages that they can edit.

Determination of view access is delegated to the $pages->find(), so it's handled at the database level rather than via any hook. Though I'm happy to add a secondary viewable() check before including the page in the list if you think it would be helpful? Or I could add a isListable() hook directly in the ProcessPageList or something like that. It would give you some flexibility to handle situations like the one you are talking about.

I tried with a hook after Page::listable , then if it's the root node "/", it returns true. But the branches are still all listed. When I clik on one he has no access, it throw the exception.

It only uses the listable check on the page that initiates the tree. That's just to prevent a user from trying to get somewhere that they don't have access to by changing the GET vars to PageList.

Link to comment
Share on other sites

Ryan, if something could be there to make this possible, that would be awseome. The thing is I use the edit/add hook to make WHOLE branches from the root editable, like for whole language tree of a multilang site. So there's de-ch,en-ch,fr-fr,en-fr,de-de branches, and I give edit access on user level via page reference field to one or two of those, so the other languages are also visible and a little confusing, as there are so many in one PW install (I know now I could use symlinks to setup a PW for each and share templates, but I think it isn't really an option as there is central branches that all language sites need access to). I know there's different needs and situations but if used like for whole main branches it works straight forward. I don't need to give user access to a subpage only. It only root pages and all subpages of it.

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