Using templates from the database

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
purplerain12
Forum Members
Forum Members
Posts: 110
Joined: Thu Aug 14, 2008 10:33 am

Using templates from the database

Post 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
rw
Forum Members
Forum Members
Posts: 28
Joined: Thu Nov 08, 2007 7:09 am

Re: Using templates from the database

Post 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.
purplerain12
Forum Members
Forum Members
Posts: 110
Joined: Thu Aug 14, 2008 10:33 am

Re: Using templates from the database

Post by purplerain12 »

Hello rw,

Thank you verry much.

Now it works fantastic.
purplerain12
Forum Members
Forum Members
Posts: 110
Joined: Thu Aug 14, 2008 10:33 am

Re: Using templates from the database

Post 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').'';
Last edited by purplerain12 on Fri Feb 20, 2009 11:16 am, edited 1 time in total.
rw
Forum Members
Forum Members
Posts: 28
Joined: Thu Nov 08, 2007 7:09 am

Re: Using templates from the database

Post by rw »

Did you also copied the _Admin... functions into your Moduluname.module.php file?
purplerain12
Forum Members
Forum Members
Posts: 110
Joined: Thu Aug 14, 2008 10:33 am

Re: Using templates from the database

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

Return to “Developers Discussion”