Module: Edit Theme Templates
Posted by Ravenswood
All files from this thread
| File Name | File Size | Posted by | Date | ||
|---|---|---|---|---|---|
| edit_templates.zip | 5.7 KB | open | download | Ravenswood | 07/13/2009 | Read message |
|
June 26, 2009 04:25PM |
Registered: 1 year ago Posts: 223 |
This module allows you to edit theme template files directly from the admin menu, without having to go through the trouble of logging in via ftp. It was inspired by the built-in editor in Wordpress.
For safety reasons (and to avoid inundating people with a huge list of files to edit), it only allows you to edit css.tpl, settings.tpl, header.tpl, and footer.tpl. Of course, you can change this by hacking the module and editing the list. See the README file for details.
No real bells or whistles. It just lets you select a template, load a file from that template, edit, and save. You MUST back-up your templates before using this module. It doesn't save a backup or provide any backing-out functionality.
This module doesn't use any hooks, by the way. Everything is done through its "Settings" screen.
For more information and a screen-shot, click here.
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
Edited 1 time(s). Last edit at 07/13/2009 01:31PM by Ravenswood.
For safety reasons (and to avoid inundating people with a huge list of files to edit), it only allows you to edit css.tpl, settings.tpl, header.tpl, and footer.tpl. Of course, you can change this by hacking the module and editing the list. See the README file for details.
No real bells or whistles. It just lets you select a template, load a file from that template, edit, and save. You MUST back-up your templates before using this module. It doesn't save a backup or provide any backing-out functionality.
This module doesn't use any hooks, by the way. Everything is done through its "Settings" screen.
For more information and a screen-shot, click here.
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
Edited 1 time(s). Last edit at 07/13/2009 01:31PM by Ravenswood.
|
July 05, 2009 10:49AM |
Registered: 2 years ago Posts: 123 |
|
July 06, 2009 05:46AM |
Registered: 1 year ago Posts: 223 |
It was written and tested on a system running 5.2.11. When I tried it on 5.2.10, I received this error message:
"Fatal error: Call to undefined function phorum_admin_build_url() in /home/xxxx/public_html/phorum/mods/edit_templates/settings.php on line 137"
Are you getting this error?
I've attached a workaround, edit_templates_for_5_2_10.zip, which should work for you. Please try it and let me know. Thanks.
Also, I'd like to ask the Phorum guys what would be the "proper" way to handle this in Phroum 5.2.10. The line is:
Thank-you.
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
"Fatal error: Call to undefined function phorum_admin_build_url() in /home/xxxx/public_html/phorum/mods/edit_templates/settings.php on line 137"
Are you getting this error?
I've attached a workaround, edit_templates_for_5_2_10.zip, which should work for you. Please try it and let me know. Thanks.
Also, I'd like to ask the Phorum guys what would be the "proper" way to handle this in Phroum 5.2.10. The line is:
$mods_url = phorum_admin_build_url(array('module=mods'));
Thank-you.
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
|
July 06, 2009 06:07AM |
Admin Registered: 7 years ago Posts: 7,731 |
Unfortunately there is no generic function to build admin urls in 5.2.10. This function was added for the CSRF protection in 5.2.11.
@Rabarbervin: you should really upgrade quickly. We didn't call it a security release without a cause. Your templates will still work in 5.2.11 and modules should have just minor issues with the new admin code.
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
@Rabarbervin: you should really upgrade quickly. We didn't call it a security release without a cause. Your templates will still work in 5.2.11 and modules should have just minor issues with the new admin code.
Thomas Seifert
Phorum Development Team / Phorum-Support.de
Custom Phorum Development
Personal Blog
|
July 11, 2009 07:17AM |
Registered: 2 years ago Posts: 123 |
I´m sorry for not being able to respond earlier (been away).
Ok.. i will upgrade to 5.2.11 and let you know if this module works.
another thought i had was that the templet i used didn´t "like" this module (simple rounded)
Rawenswood:
No i do not get any message at all, just a blank page.
u will here from me soon.
Rabarbervin
Edited 1 time(s). Last edit at 07/11/2009 07:20AM by Rabarbervin.
Ok.. i will upgrade to 5.2.11 and let you know if this module works.
another thought i had was that the templet i used didn´t "like" this module (simple rounded)
Rawenswood:
No i do not get any message at all, just a blank page.
u will here from me soon.
Rabarbervin
Edited 1 time(s). Last edit at 07/11/2009 07:20AM by Rabarbervin.
|
July 11, 2009 07:36AM |
Registered: 2 years ago Posts: 123 |
|
July 11, 2009 11:33AM |
Registered: 1 year ago Posts: 223 |
You're welcome. I'm glad it's working for you.
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
|
July 13, 2009 01:38PM |
Registered: 1 year ago Posts: 223 |
Updated the "Edit Theme Templates" mod, just a couple of minor tweaks:
It now features a link that allows you to open your forum in a new window. This is to make it easy to preview the effects of the edits you've made.
Also, this mod can now be used in Phorum version 5.2.10.
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
Edited 3 time(s). Last edit at 07/13/2009 01:50PM by Ravenswood.
It now features a link that allows you to open your forum in a new window. This is to make it easy to preview the effects of the edits you've made.
Also, this mod can now be used in Phorum version 5.2.10.
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
Edited 3 time(s). Last edit at 07/13/2009 01:50PM by Ravenswood.
|
July 16, 2009 01:56PM |
Admin Registered: 5 years ago Posts: 7,794 |
Nice module idea. Thanks for writing it!
Here's an architectural idea. Maybe you want to adapt the module to it, maybe you don't. That's up to you or somebody that gets inspired by the idea.
What is possible instead of overwriting template files directly, is storing the modified templates in the database. The next thing to do, is make sure that these database templates are shown instead of the default templates. For that you could:
In a bit of pseudo code:
And for page 'css' for example, the mods/foo/templates/emerald/css.tpl would look like:
I hope this gets the idea across. I didn't try it all out, but it just might work. Advantages of this method would be:
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
Here's an architectural idea. Maybe you want to adapt the module to it, maybe you don't. That's up to you or somebody that gets inspired by the idea.
What is possible instead of overwriting template files directly, is storing the modified templates in the database. The next thing to do, is make sure that these database templates are shown instead of the default templates. For that you could:
- create a module template mods/foo/templates/emerald/<template>.tpl
- use the hook "get_template_file" to override the requested Phorum "<template>" with "foo::<template>"
- show the database template contents from the module template "foo::<template>"
In a bit of pseudo code:
Language: PHPfunction phorum_mod_foo_get_template_file($data) { global $PHORUM; $page = $data['page']; if (we_have_an_overridden_template_for($page)) { $PHORUM['DATA']['DBTEMPLATE'][$page] = get_overridden_template_for($page); $data['page'] = 'foo::' . $page; } }
And for page 'css' for example, the mods/foo/templates/emerald/css.tpl would look like:
{DBTEMPLATE->css}
I hope this gets the idea across. I didn't try it all out, but it just might work. Advantages of this method would be:
- No issues with file permissions;
- No need to make the files writable for the webserver (kind of the same issue as the first one, but stressing the possible security issue);
- Original templates wouldn't be overridden. In case an error is made by the administrator, it is simple to allow a rollback to the original template file contents.
Maurice Makaay
Phorum Development Team
my blog
linkedin profile
secret sauce
|
July 16, 2009 02:24PM |
Registered: 1 year ago Posts: 223 |
I'm definitely going to have to implement that in the next version. Thanks for the idea!
Also thanks for the pseudo-code. Gives me a good starting point. I didn't know templates could be stored in the database. Actually, I'm learning more about Phorum all the time. I look at stuff I wrote a week ago and think, "Man, I could have done that better. I was such a noob then..."
-------------------------------------------------------------------
"When given a choice, always choose monkeys."
Sorry, only registered users may post in this forum.
