Page 1 of 1
Editable template for Gastbuch module
Posted: Sun May 14, 2006 1:52 pm
by Dee
I recently got involved in the development of the gastbuch/guestbook module. One of the last things that needs to be done for the module is to make the front end configurable (see for example this posting in a German forum:
http://forum.cmsmadesimple.org/index.ph ... 092.0.html -
at the moment after installing the guestbook, you'll have choose a template and edit to your likings, make a stylesheet for it and attach it to the template used).
I'd like to modify the module so that the front end template can be edited from the admin page and provide a default stylesheet.
Maybe someone can give me some clues on how to do this or point me to some modules that have these features built in already?
[edit]
Just found out the news module has editable templates

Will take a look at that first, please don't hesistate to reply in the meantime

[/edit]
Re: Editable template for Gastbuch module
Posted: Sun May 14, 2006 2:14 pm
by calguy1000
the normal process is to have the module create a database template on install, and provide a form for editing that database template (or templates) on the admin side. The css information is usually added to the active stylesheet for the template in the normal wah (Create a new stylesheet, add your css for the module in there, and then attach it to the template(s).
If you want a model as to how this is done, well the database templates anyways, you can look at the MenuManager, Uploads, FrontEndUsers, SelfRegistration... modules
Re: Editable template for Gastbuch module
Posted: Sun May 14, 2006 2:16 pm
by Dee
Thanks calguy. So you leave the css to the end user (no default)?
I'll take a look at some modules with an editable database template, think I'll be able to figure that out.
Re: Editable template for Gastbuch module
Posted: Sun May 14, 2006 2:19 pm
by calguy1000
Yeah, normally, I try to use as little css in my default database templates as possible, and leave it up to the site designer to style all of this stuff.
This give's a reasonable default presentation, and allows for easy customizing. All the site designer has to do is wrap a around the module tag, or inside the database template, and style to his hearts content.
Re: Editable template for Gastbuch module
Posted: Tue May 16, 2006 4:12 pm
by Dee
I have the editable database template working in the SVN version of the gastbuch module.
It's all working, but there's a small glitch: I loose the breadcrumbs when the apply button is clicked (when the form is posted - a redirect takes place after the cancel and sumbit buttons are clicked and the breadcrumbs show up then, in this case of the apply button not).
I'm not at all familiar with the form functions of CMSMS modules, so I'm probably forgetting something.
What I did was simply adding a form in the same way as is done in the MenuManager module, using:
Code: Select all
$this->smarty->assign('startform', $this->CreateFormStart($id, 'admin_template', $returnid));
and handle the post in an action.admin_template.php file.
This is the full function:
Code: Select all
function DisplayAdminTemplate($id, &$params, $returnid, $message='')
{
$content = $this->getTemplate('guestbookentry_template');
$this->DisplayAdminNav($id, $params, $returnid);
$this->smarty->assign('startform', $this->CreateFormStart($id, 'admin_template', $returnid));
$this->smarty->assign('endform', $this->CreateFormEnd());
$this->smarty->assign('content', $this->Lang('templatecontent'));
$this->smarty->assign('inputcontent', $this->CreateTextArea(false, $id, $content, 'templatecontent'));
$this->smarty->assign('submit', $this->CreateInputSubmit($id, 'submit', lang('submit')));
$this->smarty->assign('cancel', $this->CreateInputSubmit($id, 'cancel', lang('cancel')));
$this->smarty->assign('apply', $this->CreateInputSubmit($id, 'apply', lang('apply')));
echo $this->ProcessTemplate('edittemplate.tpl');
}
Anyone an idea?
Re: Editable template for Gastbuch module
Posted: Tue May 16, 2006 5:04 pm
by Dee
DisplayAdminTemplate is called from action.admin_template.php:
Code: Select all
<?php
// only let people access module preferences if they have permission
if ($this->CheckPermission('Modify gastbuch'))
{
if (isset($params['submit']) || isset($params['apply']))
{
$this->SetTemplate('guestbookentry_template', $params['templatecontent']);
}
if (isset($params['cancel']) || isset($params['submit']))
{
$this->Redirect($id, 'defaultadmin', $returnid);
}
else
{
$this->DisplayAdminTemplate($id, $params, $returnid);
}
}
?>
Re: Editable template for Gastbuch module
Posted: Tue May 16, 2006 5:18 pm
by Dee
This is the start of the form being generated/shown:
Code: Select all
<form id="m1_moduleform-1" name="m1_moduleform-1" method="post" action="moduleinterface.php"><div class="hidden"><input type="hidden" name="mact" value="gastbuch,m1_,admin_template,0" /></div>
Re: Editable template for Gastbuch module
Posted: Tue May 16, 2006 9:18 pm
by Dee
I released 0.9 (
http://forum.cmsmadesimple.org/index.ph ... 649.0.html) with the breadcrumb twitch in it, as I'm not sure if it's a bug in the gastbuch module or in the breadcrumbs (Ted told me in the FCK module the same thing happens).