Jump to content

Admin Custom Pages Module


diogo

Recommended Posts

Admin pages can have segments and they're mapped to the function in the process module attached to it. But that's not the urlSegments you can use on frontend.

Like /adminpage/edit

Will call executeEdit() method in the process module. I'm not sure how custom admin pages work and that's maybe not possible as you don't use process module to make the admin page.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Just wanted to confirm that I am seeing the same issue as Macrura. If you need a quick fix for a live site, you can grab the templates-admin folder from the last PW version before Ryan introduced the module theme technique and this module will look as expected again.

Link to comment
Share on other sites

right - actually i'm not sure if i have that... i tend to overwrite my dev versions with the latest when i download them...

it's not a huge deal except for the fact that i was using fontawesome on these custom pages and that no longer works..

i did try copying the admin-templates from the wire into the site, directory to see if i could get the fontawesome to work.. guess i either need to deal with it for the time being or revert to the old theme by uninstalling that admin theme module

Link to comment
Share on other sites

Hi guys, thanks for the report and a quick answer. I can't have a look at this that soon but If you guys would like to make a pull request on git I'll be happy to accept it.

Link to comment
Share on other sites

how do I adjust now the current admin theme to the module ? 

Is this question specific to the AdminCustomPages module or specific to the admin theme in the PW dev branch? If admin theme in dev branch, you can remove or rename whatever theme you have in /site/templates-admin/. Then go to Admin > Modules > Core > Default Admin Theme and click "install". 

Link to comment
Share on other sites

how do I adjust now the current admin theme to the module ?

I think the issue here is that the Admin Custom Page module is not aware of the new admin theme being in a module, so your custom admin pages still retain the non-module theme. We'll have to take a look at the code and see if there's a way to make some adjustments to how the module loads the theme.

  • Like 1
Link to comment
Share on other sites

Is this question specific to the AdminCustomPages module or specific to the admin theme in the PW dev branch? If admin theme in dev branch, you can remove or rename whatever theme you have in /site/templates-admin/. Then go to Admin > Modules > Core > Default Admin Theme and click "install". 

Its specific to the AdminCustomPages  ;)

I've tried self to adjust the them but it doesnt really works. If im right

then :

I can insert my own code in the AdminCustomTheme template. 

For example I try to write currently an Real Estate XML import. 

So I can start the import from the AdminCustomPage ?

Maybe on Press "Import Button" or something like this ? 

Link to comment
Share on other sites

  • 1 month later...

@Diogo - with this module in PW 2.4, it loads the theme from /wire/templates-admin/ instead of the new admin theme.

  1. Not sure why there is still an admin theme in /wire/templates-admin/ in the latest download
  2. I have no idea why it's not defaulting to the new theme as every other admin page does
Link to comment
Share on other sites

@Diogo - with this module in PW 2.4, it loads the theme from /wire/templates-admin/ instead of the new admin theme.

  • Not sure why there is still an admin theme in /wire/templates-admin/ in the latest download
  • I have no idea why it's not defaulting to the new theme as every other admin page does

1. It is the translation source. See here and here

2. Is that because the new admin theme is a module? //Silly me; but other modules are working, duh!

2. It's not loading the new admin theme css files...why, I don't know...:-)

Link to comment
Share on other sites

@Pete - yeah this issue has been sort of lurking here and there on different threads...

the thing is that making your own process module really is not a replacement for what this module offers in terms of ease, flexibility and speed in setting up custom admin pages;
 

I spent at least 1 hr trying to change stuff in the module code to make it use the admin theme module, but i just couldn't figure it out; In the end the only way was to modify the index.php as was mentioned here...
 

I'll be really happy once this issue of the wrong template file loading is sorted on this module!!

Link to comment
Share on other sites

the thing is that making your own process module really is not a replacement for what this module offers in terms of ease, flexibility and speed in setting up custom admin pages;

I have to disagree. Never actually tried this module (since I don't fully understand it's purpose). If you compare instructions for this module (https://github.com/ocorreiododiogo/pw-admin-custom-pages) and those provided by boilerplate for Process modules (https://github.com/ryancramerdesign/ProcessHello), there is no much difference in complexity. I actually find latter easier (only changing file, class and constant names if you want to make it your own instead of "hello").

There is designed way to extend PW admin with own pages, and that is through Process modules (which are super simple, just install ProcessHello, play with it 15 minutes and you get it). Anything else is just looking for troubles in long run.

I am sure there is something that makes Process-modules seem harder than they are. I guess that is the reason why Diogo has build this module..?

  • Like 1
Link to comment
Share on other sites

For me, all I wanted it for was to create dashboards which I've just created a module for: http://processwire.com/talk/topic/5785-processdashboard/

Whilst I've made it really easy in my module for people to use a template file instead of touching the module, you're right in that ProcessModules are fairly easy to get along with once you take the plunge, so I've been sure to mention the ProcessHello module there as some encouragement for folks to roll their own modules.
 

Link to comment
Share on other sites

I agree — ProcessModules are the way to go. They might look intimidating at first, but if you start with a very simple example, they really are very easy.

Here is a super simple example that lists all pages with the template "news".
(I'm sure there are others out there, but it only took a few minutes to write so...)

<?php

/**
* Simple Process Module Example.
* This is a very basic example to learn from.
* I have no intention of expanding on this sample module.
*
* @author renobird
*
* ProcessWire 2.x 
* Copyright (C) 2011 by Ryan Cramer 
* Licensed under GNU/GPL v2, see LICENSE.TXT
* 
* http://www.processwire.com
* http://www.ryancramer.com
*
*/

class SimpleProcessModule extends Process {
    
    public static function getModuleInfo() {
        return array(
            'title' => 'Process Module (basic example)',
            'summary' => 'A very simple process module as an example on how easy they are to create.',
            'version' => 100,
            'href' => '',
            'permission' => ''
        );
    }
    
    public function init() {

        // initialize the parent
        parent::init();

    }
    
    public function ___execute() {

        // Find some pages
        $items = $this->pages->find("template=news");

        /**
         * Create a table to display results
         * There are other ways to do this using MarkupAdminDataTable module, but let's keep this simple for now.
         */
        
        $out = "<table width='100%'>";
        $out .= "<thead>";
            $out .= "<th>Title</th>";
            $out .= "<th>Date Created</th>";
            $out .= "<th>User</th>";
        $out .= "<thead>";
        $out .= "<tbody>";

        // If $items pageArray is not empty
        if ($items->count() > 0){

            foreach ($items as $item) {
                $out .= "<tr>";
                $out .= "<td><a href=". $this->config->urls->admin . "page/edit/?id=" . $item->id .">" .$item->title . "</a></td>"; // title
                $out .= "<td>" . date("F j, Y", $item->created) . "</td>"; // date created
                $out .= "<td>" . $item->createdUser->name. "</td>"; // user that created
                $out .= "</tr>";
            }

        } else {
            
            // empty pageArray message
            $out = "<tr><td>No pages matching your criteria were found.</td></tr>";

        }

        $out .= "</tbody>";
        $out .= "</table>";
        
        return $out;
    }
}

Usage:

  1. Install the module
  2. Create a new page under /admin/
  3. Set the process for the new page to SimpleProcessModule

If you have never created a module, just focus on the execute() method.

Most of what is there is coded exactly as you might from a page template.

  • Like 12
Link to comment
Share on other sites

I agree that it's not difficult to create simple process modules, but I think it's great to be able to use normal templates in the admin. The idea of the module is that people don't have to change the way that they write code in pw or learn a new concept just to create a couple of backend pages. I do think that the module makes it easier to create admin pages (when it's working at least).

I'll try to fix it as soon as I have some time.

Edit: I didn't use the module for some time, but I did it now and I'm always amazed with how easy it is to create a custom page with it :P

  • 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
  • Recently Browsing   0 members

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