Page 1 of 1

Using templates from the database

Posted: Thu Feb 19, 2009 6:03 pm
by purplerain12
Hello,

I am writing my own module. It's almost finished.

But know i want to add a tab so users can edit the template or add a template of there own. I tried, but i faild. Can someone help explain how i can get a template in to the database?

I think i know how i can get the template to show in the textarea in the admin panel and then to save the template after editting. Because i think that's nothing more then making a form.

But i am having trouble getting the template in to the database when the module gets installed.

I hope someone can give me a good explanation, because the information i found on this wbesite don't help me much.

Thanks.

Regards,

Bas

Re: Using templates from the database

Posted: Thu Feb 19, 2009 10:07 pm
by rw
You can best take a look at the news module as this one is well done and in there you can see how it has been done. Also take a look at my post below about the PicasaWebAlbumBrowser as I also managed to do this lately.

Basically you should have:
  • .tpl files in a template folder;
  • modify/create method.install.php and create databasetemplates based upon the .tpl files;
  • modify/create action.defaultadmin.php and make the tabs with an edit feature;
For the action.defaultadmin.php section you will need the functions _AdminEditDefaultTemplateForm and _AdminCreateTemplateList as you can find them in the News.module.php

Hope you can do something with this information.

Re: Using templates from the database

Posted: Fri Feb 20, 2009 9:58 am
by purplerain12
Hello rw,

Thank you verry much.

Now it works fantastic.

Re: Using templates from the database

Posted: Fri Feb 20, 2009 11:13 am
by purplerain12
Well, not perfectly.

I managed to create a field for my template in the cms_module_templates table on install.

I looked at the News module how to create a list of templates in the the tab. But this doesn't work yet.

I used the _AdminCreateTemplateList function. Nothing happens. I used the code in the action.defaultadmin.php and changed it to my prefrences. I only see the title i called:

echo ''.$this->Lang('title_available_templates').'';

Re: Using templates from the database

Posted: Fri Feb 20, 2009 12:17 pm
by rw
Did you also copied the _Admin... functions into your Moduluname.module.php file?

Re: Using templates from the database

Posted: Fri Feb 20, 2009 2:12 pm
by purplerain12
Nope, i didn't.

But i do have the option to edit one template from the database. Users can't add a new template now, but that's ok.

I need to have some work for the next version of courseĀ  ;).

Thanks, i will look into this later.