diogo

Admin Custom Pages Module

Recommended Posts

How do i use a regular page as an admin page, in this case a settings page with a template who has no file attached to it. My problem is that the module requires a php file to output data, all i want is to have my /settings/ page in the top menu of the admin, no custom markup whatsoever.

I have used this tag from here:

if($page->template=="admin" && $page->name=="settings") $input->get->id = $pages->get("/settings/")->id;

The problem with this is that it will automatically use the "ProcessPageEdit" Icon.

My question follows: How do i get my /settings/ page to the top meny using this Module?

Share this post


Link to post
Share on other sites

i don't have a file for my settings page, and it works because of the code you put into ready.php

in terms of the icon, if you are on Reno you set the icon from the module settings

to get your settings to the top menu, just move the admin page to the top of the list.

Share this post


Link to post
Share on other sites

The Solution above worked well but wont work if i want more control over the template.

I got a custom list of pages to work within this module:

<?php

$p = $this->modules->get('ProcessPageList'); // kongondo's code goes here
$p->set('id', 1166); // setting the parent page

$pageTree = new InputfieldMarkup; // the placeholder
$pageTree->value = $p->execute(); // fill the InputfieldMarkup form field...

echo $pageTree->render(); //or return if in a function...

?>

But is there any way to do this for ProcessPageEdit for a specific page? (In my case a settings page)

Share this post


Link to post
Share on other sites

hi diogo,

thanks for the great module! i just moved a site from dev to live server and got an open basedir restriction error. it looked for the template file unter /var/www/site/... instead of /var/www/vhosts/xyz.com/site/...

i had to go to that page and assign the template again. maybe you can change this to use relative paths down the PW rootpath?

thanks

PS: no problems with the scripts and styles paths!

I've encountered this bug a number of times when launching, finally got around to looking into it and submitted a pull request.  Not the most elegant fix, but it seems to work.

My fork is available here: https://github.com/deeplypixelating/pw-admin-custom-pages

  • Like 3

Share this post


Link to post
Share on other sites

Hey guys! Sorry, I'm not giving great attention to the module lately and I'm tight with time right now. @evan, your pull request seems reasonable, so I will accept it as is.

Don't worry about the fix not being the most elegant. The module is naturally hacky in it's own nature already :P

  • Like 2

Share this post


Link to post
Share on other sites

Hello,

Thanks for the module.
Just played with it for the first time this week end. It worked ok on a PW2.7 test site. But I had a problem to run it on a PW3.0.18dev.

On the the PW3 site, the installation of the module and the creation of the page return no error. But I get the following error message when I want to view the custom admin page I have created.

 TemplateFile: Template file does not exist: '/Applications/MAMP/htdocs/XXX/site/templates/Applications/MAMP/htdocs/XXX//site/templates/testselector.php'

and in the page its written 'the process return no content'.

The adresse shown in the error message is wrong as the path to the root is added 2 times.

this site is a test site whit just a bare install of PW3.

am I doint something wrong Or is it just not compatible yet with PW3 ?

Share this post


Link to post
Share on other sites

It's an error in my fix -- errant leading slash.  You can pull down my branch until the pull request is accepted, or just correct it in your copy of your module.

Replace line 55 in FieldtypeAdminCustomPagesSelect.php:

'path' => "/" . str_replace(wire('config')->paths->root, '', $file), // Make path relative

with:

'path' => str_replace(wire('config')->paths->root, '', $file), // Make path relative

Hopefully that works for you!

Share this post


Link to post
Share on other sites

I'm using this module recently to put items to the sidebar, and works well. However, when it comes to editors, they don't have access to pages under Admin, so they can't access these sites. Of course I could add them permission but that's risky.

So I went with this route:

  • add a Page under Admin, set a template file to it (_sidebar-item.php)
  • create a page under the Home with similar name
  • in _sidebar-item.php get the page under Home:
<?php namespace ProcessWire;

$p = $this->modules->get('ProcessPageList');

// try to get a similarly named page in root
$rootPage = wire('pages')->get('parent=1, name=' . wire('page')->name);

if ($rootPage->id) {
    $p->set('id', $rootPage->id);
    return $p->execute();
}

This way non-superusers can see the sidebar item and have permission to edit (because the loaded page has a non-admin template). Without this they would get "You don't have access to list page /admin/.../".

  • Like 2

Share this post


Link to post
Share on other sites

@PWaddict I think you can add icons only to templates, and not individual pages. On the instructions I tell you to give the "admin" template to the pages, but I guess you could create a new template for it as long as it has you assign the "process" field to it. Be aware that this field won't appear on the select when assigning fields to templates, so you will have to create the template and then go to the fields list —  show built-in fields — edit the "process" field — from there, add it to your new template.

Share this post


Link to post
Share on other sites
7 hours ago, diogo said:

@PWaddict I think you can add icons only to templates, and not individual pages. On the instructions I tell you to give the "admin" template to the pages, but I guess you could create a new template for it as long as it has you assign the "process" field to it. Be aware that this field won't appear on the select when assigning fields to templates, so you will have to create the template and then go to the fields list —  show built-in fields — edit the "process" field — from there, add it to your new template.

Thanks for the reply. My custom page includes some text and the icon for the navigation so I find it easier to create a custom process module for it.

Share this post


Link to post
Share on other sites

you can also set the icon in the AdminThemeReno settings, if you are using that Admin theme.

  • Like 1

Share this post


Link to post
Share on other sites

I have used this module successfully in the past, but am having trouble getting it to work properly in PW 3.0.123.

The module installs without error and I can create an admin page (using the admin template and the correct "Process."), but the FieldTypeAdminCustomPagesSelect field never shows up on the page. (The field is defined in the fields table.) I manually entered a value in field_acp_template to try and circumvent the issue, but it's not finding the template file.

What else should I check? Any ideas?

Thanks!
Jason

 

Share this post


Link to post
Share on other sites

Just to follow up, I discovered that there was no entry in the fieldgroups_field table linking the missing field to the admin template. I manually added a record there, re-saved my custom page, and now it's working as expected.

I am concerned about how the db got into this state in the first place, but I don't think this module is to blame.

Thanks,
Jason

 

 

Share this post


Link to post
Share on other sites

@Jason Huck I'm glad you managed to solve the problem. Regarding the DB, this doesn't sound like something that could be caused by the module.

I didn't update the compatibility of the module to PW3 because I didn't test it enough. Although I still think this module is convenient and makes it really easy to add new admin pages, the truth is that it relies on a hack, and I would advise anyone to have a look first at this tutorial on creating admin pages the proper way written by @bernhard before deciding to use it.

  • Like 1

Share this post


Link to post
Share on other sites

Don't want to discredit your work, but maybe a note/link in the first post of this topic would make sense? Not saying that people should use "my" way, but it might make sense to mention it there so that they can make an educated decision 🙂 

  • Like 1

Share this post


Link to post
Share on other sites
2 hours ago, bernhard said:

Don't want to discredit your work, but maybe a note/link in the first post of this topic would make sense? Not saying that people should use "my" way, but it might make sense to mention it there so that they can make an educated decision 🙂 

Good idea, Just did that! Also added it to the README.

  • Thanks 1

Share this post


Link to post
Share on other sites

By the way, I took a moment to test the module and it seems to be working pretty well on PW3, so I updated the compatibility info.

  • Like 1

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.