Jump to content
gRegor

Process module adding items to sidebar template without file

Recommended Posts

This is kind of a theme-related question (Reno), but also a Process module question, so posting it here.

I have a Process module I use to display new menu items in the left sidebar (Reno theme) for documentation. I handle displaying the documentation content through the module's ___execute and ___executeView methods, so I don't have a template file. The problem I'm running into is that the theme checks viewable() (reference) on each child page, and since there's no template file, none of the child pages get listed in the sidebar.

I'm wondering if there's some way to get around this "viewable" issue. I tried setting the documentation pages template to "admin" but as expected, viewing them gives me a "this page has no process assigned" error message.

I think this might be a feature request for the Reno theme, really, but wanted to post first in case someone had a quick solution I'm overlooking. Thanks!

Page structure:

- Admin
-- Documentation (template: admin, process: ProcessDocumentation)
--- How to do x, y, z (template: documentation, no associated template file)
--- How to do another thing (same)
...

Share this post


Link to post
Share on other sites

Why not hook into Page::viewable and, if the template is documentation, apply your own logic?

  • Like 3

Share this post


Link to post
Share on other sites

From the php docblock documentation:

Quote

- Optionally specify boolean false as first or second argument to bypass template filename check.

 

  • Like 4

Share this post


Link to post
Share on other sites

Good suggestion. That works to make the collapsible sidebar work in Reno, but when I click on one of the documentation pages I get a blank page. I guess the documentation template doesn't execute the parent page's Process, so the execute method doesn't get called? Is there any way to achieve this without needing to assign a Process to each documentation page?

Share this post


Link to post
Share on other sites

Bump. Any ideas on this?

I've now tried setting up the documentation.php template file with:

$page->process = 'ProcessDocumentation';
require($config->paths->adminTemplates . 'controller.php');

Based on admin.php, I would expect this to display the page contents in the default admin theme (Reno), but alas, it displays it in the legacy frontend layout (edit: the "skyscrapers" demo, though the navigation is all of the admin links). I've tried setting $config->defaultAdminTheme = 'AdminThemeReno'; in config.php but still no dice. I'm baffled at this point.

This is in PW 2.7.2

Edit edit: Alright after digging more, upgrading to 2.8.35, and digging even further, I feel pretty confident this is a bug, so I opened an issue.

Share this post


Link to post
Share on other sites

A bit off-topic, but have you considered any alternative ways of displaying documentation other than the approach your taking?

For instance, it seems like it would be a lot simpler if your documentation pages were displayed on the front-end. What I do for client documentation is this:

1. Create a documentation template. Don't give users edit access to pages using this template.

2. In the template file, perform a check that the user is logged in with the appropriate role, otherwise throw a 404.

3. Create documentation page(s) via the PW admin. I just use a single long page with a table of contents and anchor links but multiple pages would work equally well.

4. Insert links to the documentation page(s) into the admin theme for easy user access. I do this using jQuery via AdminCustomFiles because it's dead simple, but I think a hook would work too.

Share this post


Link to post
Share on other sites

I realized that's possible, but hadn't considered it much as an option. Since the documentation we're setting up is for doing specific tasks in the admin area, it seems a bit clunky to send them to a front-end page and then they have to return to the admin. I appreciate the idea, though!

Share this post


Link to post
Share on other sites

@gRegor - not sure if you already tried the Admin Help module, which is basically a documentation system that runs inside PW admin; one of the sub-modules is a process module that displays all of the documentation in an accordion page view...

  • Like 2

Share this post


Link to post
Share on other sites

Just wanted to share what I ended up doing.

After a lot of digging and various attempts (see github), I gave up on having the documentation sub-pages show up in the sidebar. That means I was able to move the documentation pages elsewhere. I've been in the habit of having a page Backend Tools which doesn't have a template (so not available to the public) and store groups of pages there for things like Page-select options. I added a sub-page there Documentation Pages which allows children with template Documentation. The Documentation template just has a title and body field.

Then in my ProcessDocumentation module, the ___execute() method shows a list of all the Documentation pages, linking to them with the format: ./view/[page-name]. Then the __executeView() method verifies the page-name is valid and if so, returns the documentation page's body field, so it shows up in the admin theme. There's still a link to the main documentation page in the sidebar, which I think is good enough. Voila.

Share this post


Link to post
Share on other sites

Fyi AdminOnSteroids module is able to put pages to the sidebar. It is using Javascript to append the pages because there's no hook I could use so it may not fit your needs.

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By tpr
      ProcessNetteTester
      Run Nette Tester tests within ProcessWire admin.
      (continued from here)

      Features
      AJAX interface for running Nette Tester tests, in bulk or manually display counter, error message and execution time in a table run all tests at once or launch single tests show formatted test error messages and report PHP syntax errors stop on first failed test (optional) hide passed tests (optional) display failed/total instead passed/total (optional) re-run failed tests only (optional) auto scroll (optional) include or exclude tests based on query parameters start/stop all tests with the spacebar reset one test or all tests (ctrl+click) TracyDebugger File Editor integration https://modules.processwire.com/modules/process-nette-tester/
      https://github.com/rolandtoth/ProcessNetteTester
    • By hollyvalero
      I like the Reno wrapper for the admin.  After looking at UIKit, then switching back to Reno, the back end is all Reno but the basic back end login page /processwire or /whateveryoucallit is displaying the original Default instead of the Reno login.  I realize this is a first world problem, but I can't seem to reinstate the Reno login.  Tried installing/uninstalling...  It's not the same page code and it's not the same style sheets... I can't uninstall the default ...what am I doing wrong?

    • By Mustafa-Online
      How To Show User Actual Name Insteal of "user-name" .. I'm Using "AdminThemeReno" here.
      .

    • By gebeer
      Hello,
      I have a Process module with a user dashboard and I would like to have the user page edit screen at a custom URL 'myprofile'.
      I cannot use the default profile edit page because it does not support tabbed interfaces.
      The method for executing the user edit page from within my module looks like this
      public function ___executeMyprofile() { $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } The user edit screen displays when I go to /dashboard/myprofile. But the request is redirected several times and I end up at the URL /access/users/edit/?id=5522 which I wanted to avoid.
      This happens because of this line in ProcessPageEdit.module.
      I guess the solution lies in hooking into the ___loadPage() method from within my Process module. But, honestly, I have no clue on how to put the pieces together.
      So I need some pointers on how to best achieve the goal of having the current user's edit page under a custom URL in the admin area, ideally in the scenario of a custom Process module.
      Any help would be much appreciated.
      EDIT:
      I tried some variations of hooking like
      public function ___executeMyprofile() { $this->addHookBefore("ProcessPageEdit::loadPage", $this, "interceptRedirect"); $processUser = $this->modules->get('ProcessUser'); return $processUser->executeEdit(); } protected function interceptRedirect(HookEvent $event) { $event->replace = true; $event->return = $this->user; } but the hook is not being executed at all. Also when placing the call to the hook in my Process module's init() method. Also when using an After hook and not replacing the hooked method. No luck so far...
    • By AndZyk
      Hello,
      this is a small request, but since a while I develop exclusive in Google Chrome and if I have the developer tools open and try to access the back end, I always get following notification:
      It seems like the Chrome developer tools are looking for a css map file inside the AdminThemeReno, which is not present.
      Maybe this doesn't bother anybody and it is rare, that I try to access the back end with the developer tools, but I just wanted to point this out. 
      Regards, Andreas
×
×
  • Create New...