diogo Posted December 17, 2012 Share Posted December 17, 2012 I was thinking of a way of creating custom admin pages without having to create a process module or having to use the $wire object. I came up with a process that is actually very simple (although I think it would be better to create a module for having this functionality). Here is how: (This will work with the default admin theme, but should also work with other themes) Go to your /site/templates-admin/default.php (if you don't have it, copy the /wire/templates-admin/ directory to /site/) and change this line <?php echo $content?> to this <?php if($page->template===$templates->admin){echo $content;}else{include($config->paths->templates.$page->template->name.".inc");}?> Then, go to the /site/templates/ folder and create a file named "custom.php" with this content <?php include($config->paths->adminTemplates."default.php"); Our setup is ready Now, to create a custom page in the admin: First, create the new page as child of /Admin/ and point to custom.php as the template file. To do this, when creating the template for the page, go to "ADVANCED" and write "custom" as the "Alternate Template Filename". Then, instead of creating a TEMPLATE.php file, as you normaly would, create a TEMPLATE.inc file. You can use all the API variables as you would in a normal template. Disclaimer: This is a proof of concept, and has still lot's of place for improvement. edit: changed from this if($page->process) to this if($page->template === $templates->admin) 8 Link to comment Share on other sites More sharing options...
ryan Posted December 19, 2012 Share Posted December 19, 2012 Looks like a cool technique Diogo! I've created custom admin page for clients to do various things. Usually I'll create a Process module to take care of it. But there have been a couple cases where I just wanted to do it with a template. In those cases, I've had it just use the site's template rather than the admin template, or alternatively just include() the admin template from my own. But will have to try this technique out next time. Link to comment Share on other sites More sharing options...
diogo Posted December 20, 2012 Author Share Posted December 20, 2012 The idea is that you don't have to create a module, I think it's very practical but unfortunately it depends on changing code in the theme, so making a module for this would be more logical. Link to comment Share on other sites More sharing options...
ryan Posted December 22, 2012 Share Posted December 22, 2012 Well admin themes are a type of module themselves, in that they are modular and meant to be swapped easily. Link to comment Share on other sites More sharing options...
Nelson Posted January 8, 2013 Share Posted January 8, 2013 Hi there, I've created custom admin page for clients to do various things. Usually I'll create a Process module to take care of it. I'm trying to create a page like this but I've still not figured how would be the best way to store the data of a custom admin page. For example, a page with only a email field, how you would setup this? Custom table? I'm using your https://github.com/r...gn/ProcessHello module as base for this. Sorry for breaking in your thread diogo. Link to comment Share on other sites More sharing options...
arjen Posted January 8, 2013 Share Posted January 8, 2013 A page - or perhaps do you mean a template? With only an e-mail field? How about this: 1. Setup > Fields > Create a new field > type: email. Or use the internal email field as an alternative. 2. Setup > Templates > Create a new template > Assign the email field. Link to comment Share on other sites More sharing options...
Nelson Posted January 9, 2013 Share Posted January 9, 2013 The thing is I was trying to use a Process module for setting up a custom page and I can create a template for it but then I'm unable to link my Process module to it because the process field it's not available for new templates. Link to comment Share on other sites More sharing options...
ryan Posted January 10, 2013 Share Posted January 10, 2013 The field 'process' is a system field, so you won't see it in the admin interface as an option to add to a template unless you have $config->advanced=true; in your /site/config.php. You can also add it from the API side. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now