Jump to content

Admin Custom Pages Module


diogo

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?

Link to comment
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.

Link to comment
Share on other sites

  • 1 month later...

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)

Link to comment
Share on other sites

  • 2 months later...

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
Link to comment
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
Link to comment
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 ?

Link to comment
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!

Link to comment
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
Link to comment
Share on other sites

  • 10 months later...

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

Link to comment
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.

Link to comment
Share on other sites

  • 1 year later...

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

 

  • Like 1
Link to comment
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

 

 

  • Like 1
Link to comment
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
Link to comment
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
Link to comment
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
Link to comment
Share on other sites

  • 1 year later...

HI,

Tks for the userfull module.

I bumped into a funny issue related to role and permission.

I have added a role for editors that can access backend with limited permissions (page view, page edit, some listers). For some reason, the admin custom page are shown in the setup menu. These are the only admin pages that are displayed to the editor. I  realy don't understand why. I have not change any access parameter on the admin template thats only accessible to superuser. Any idea what going on (it's a multilanguage site).

Tks for your help

Link to comment
Share on other sites

Hi @antpre,

The module doesn't do anything concerning this, it only works from the moment you are looking at that page. The place where those pages are shown in the menu is only dependent on where you place them in the tree. Try moving the page from inside the "setup", one level up, into the "admin" page. Now it should be showing as a main item in the nav. If you now place in inside the "pages" page, it will show as a subpage of that manu item.

I hope I understood your problem correctly.

Link to comment
Share on other sites

Thanks a for your answer. Sorry If I was unclear in my explanation. I am aware of what you mentioned.

I am just trying to figure out why, when the admin template has access control on and only super user can see admin template based pages, why non super user in the back end still see the Admin Custom Pages I ve created and no other admin pages. These custom admin pages  should be equally hidden in the same way than the other admin pages. But I guess that your module does not interact with access control. So I ll keep searching.

Regards

Link to comment
Share on other sites

Quite a late answer, sorry. Yes, the module doesn't interact at all with access control. You would have to do that yourself inside the template file, by creating a new permission, and throwing a 404 or printing a custom message to unauthorised users. Dealing with the menu is a bit more tricky, since, the nav uses $page->viewable(), and that's at template level, being that our template would always be "admin". I guess you could simply clone the admin template and set the permissions on that one.

Link to comment
Share on other sites

  • 2 years later...

Hi all,

Not even sure if this thread is still active so heres hoping.

Is it possible using this module to include existing fields used on other templates into the custom admin one?

I had hoped to add a couple of existing page ref fields to this page, so that if the originalls are editted, the options would then be reflected on my custom admin page.

I had thought if I just added them to the template im using for the custom page, but after adding them and then setting up the custom admin page I run into this error that stops me from publishing it.

Any ideas? I am assuming this is either not achieveable or im going about it in the wrong manner?

image.thumb.png.568ac5d83f23fdaac39c638d4affeb77.png

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