Page 1 of 2
Some questions regarding templates & stylesheet from a new user.
Posted: Sat Oct 17, 2009 11:12 am
by pjdevries
I'm quite an experienced software developer, acquainted with various other CMS's (Joomla!, Drupal, etc.) but completely new to CMS Made Simple. I also never used Smarty but have some experience with patTemplate. I have a few newbie questions, to which I haven't been able to find answers in the Documentation or Forum's:
1. Apparently CMSMS stores everything in the database, including templates and stylesheets. From what I understand, this hasn't always been the case. Although this has obvious advantages, there are also some disadvantages to this approach. What I like to know is, if it's still possible to work with old-fashioned, regular files, enabling me to use my own personal and familiar development tools. If that is still possible, I would obviously like to know how to go about that and if I lose features or functionality by doing so.
2. Which Smart version comes with CMSMS and is it possible to make use of the entire Smarty features set as described in the
Smarty documentation?
3. The two questions above result from one particular issue I encountered regarding the Smarty {include} tag. Experimenting with it, I discovered that it can not be used in combination with regular templates originating from the database. From a topic in one of the Forums I understood it can be used when using regular, if placed in the [web root]/tmp/templates directory. My question is, if it is actually possible somehow to use the {include} tag in combination with regular, database originated templates.
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Sat Oct 17, 2009 12:11 pm
by Peciura
Try module Template Externalizer
http://dev.cmsmadesimple.org/project/fi ... ackage-229 , i have not tried it with cmsms version above 1.2.5, i hote it still works.
CMSms uses Smarty 2.6.25 (last but one) version. Naturally it supports all fietures described at
http://www.smarty.net/manual/en/
Unfortunately i have not tried to use templates-files with cmsms. In my opinion there is not a big difference among including file or retrieving template as variable from DB. Actually it would be interesting to test whether file or DB cashing is quicker.
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Sat Oct 17, 2009 12:19 pm
by pjdevries
Thanks for your swift reply.
In my opinion there is not a big difference among including file or retrieving template as variable from DB.
What exactly do you mean with "retrieving template as variable from DB"? How does that compare to including a file using the {include} tag?
Actually it would be interesting to test whether file or DB cashing is quicker.
Speed is not my main consideration for asking these questions. To be honest, I didn't think of that aspect yet.
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Mon Oct 26, 2009 6:12 am
by Jeff
pjdevries wrote:
3. The two questions above result from one particular issue I encountered regarding the Smarty {include} tag. Experimenting with it, I discovered that it can not be used in combination with regular templates originating from the database. From a topic in one of the Forums I understood it can be used when using regular, if placed in the [web root]/tmp/templates directory. My question is, if it is actually possible somehow to use the {include} tag in combination with regular, database originated templates.
No it won't work with anything in the database. What are you trying to do?
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Mon Oct 26, 2009 9:14 am
by pjdevries
Thanks for the follow up.
No it won't work with anything in the database. What are you trying to do?
I consider Smarty's {include} extremely powerfull from a maintainance perspective. However, by default it only works with regular filesand not with templates which are stored in the database. Scanning through the
Smarty documentation makes clear that it can be done with a
Resource plugin. Maybe a nice additional feature for CMSMS?
By the way, can you also answer the first two questions in my original post?
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Mon Oct 26, 2009 12:49 pm
by Peciura
Have you tried Template externalizer ?
If template externalizer doesn't work continue reading.
This method doesn't work perfect it is just a start.
Page with template "test" omits content text area.
1. create template file at page root (e.g. /test.tpl)
2. Place tag to new empty template e.g. "test" (DB entry)
Code: Select all
{include file='/absolute/path/in/web/server/test.tpl'}
OR
Instead of writing static path to test.tpl you could calculate it:
2. create UDT "test":
Code: Select all
global $gCms;
$config = & $gCms->GetConfig();
if(!empty($params['assign'])){
$smarty = & $gCms->smarty;
$smarty->assign( $params['assign'], $config);
}
3. Place tags to new empty template (DB entry)
Code: Select all
{test assign=temp}
{include file=`$temp.root_path`/test.tpl}
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 12:53 am
by Dr.CSS
Would be nice to know what you are trying to include with {include}...
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 8:46 am
by pjdevries
I realize that English is not my native language, but is it really that unclear what I'm trying to achieve?
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 5:33 pm
by Dr.CSS
Yes it is unclear to me what you are trying to do...
My take on it...
You are used to doing it the other way like j*** or d*** does it, you want a bunch of files or ? all over the place and then in the template you want a bunch of includes to call the , menu, body of content, footer etc. etc. so they can all be put together when the page is called...
I think maybe you are over complicating the whole thing...
So yes I'm sure you see now that I have no idea what your trying to achieve

...
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 6:28 pm
by pjdevries
I'm afraid I'm not able to get any clearer than I have been in my previous posts. Like I mentioned, apart from advantages, there are also some disadvantages to the "templates in the database" approach and I simply want to know if it's still possible to use regular files. Secondly I want to know if and how the standard Smarty {include} tag can be used in combination with templates stored in the database. If this isn't clear enough, that's a shame and I guess I'll have to try to find the answers myself.
The fact I'm "over complicating the whole thing", is not really an issue here and difficult for you to judge, since it's unclear to you what I'm trying to achieve. I'm simply a novice, trying get some general information from experienced CMSMS users. How I use that information, is entirely up to me. I can't help feelling though, that your apparent prejudice in favor of CMSMS isn't very helpful and probably prevents you from approaching questions by new users in an objective and constructive manner.
By the way: I'm not getting into discussions about how superior CMSMS is compared to Joomla, Drupal or any other CMS out there.
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 7:16 pm
by Peciura
In this case i would say it is undeveloped, though something works.
Don't forget to back up files and DB before doing any atemps ( pays off ).
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 7:24 pm
by pjdevries
Thanks for the tips.
I'll have a look at Template externalizer as soon as I can find the time. However. untill I'm sure CMSMS is an acceptable alternative for certain commercial projects, I have to consider it a private hobby project and unfortunately I don't have much time to spend on hobbies

Hopefully I can also find some time to try to implement a Smarty resource plug-in, so the {include} tag will work effortlessly in combination with CMSMS database templates.
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 7:46 pm
by Jeff
First, of course we are going to be "closed minded" that CMSms is the best, why are we going to be working with it and developing for it if we didn't think it was?
Second, just because you say I want to be able to do this or that doesn't mean that we are going to add that feature with out justification. We have repeatedly asked what your need for using {include} in reference to database template is, and all you say is that is what I want to do. We have no need to have smarty interact directly with the database that is what the CMS is for. We are trying to help you understand the product but we can't when you are being "closed minded" in your approach to the solution.
I simply want to know if it's still possible to use regular files. Secondly I want to know if and how the standard Smarty {include} tag can be used in combination with templates stored in the database. If this isn't clear enough, that's a shame and I guess I'll have to try to find the answers myself.
We have answered your questions. We are trying to point out that there are different ways to answer the problems, if you aren't focused on one solution.
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 8:30 pm
by pjdevries
I sincerely apologize if I offended anybody. Having said that, I don't think being "closed minded" is ever a good thing. On the contrary; being very "open minded" is the only way to even come close to developing the best CMS. I don't want to offend anybody, but I do detest prejudice and being patronized.
Second, just because you say I want to be able to do this or that doesn't mean that we are going to add that feature with out justification.
Another apology for giving the impression that I was trying to force the development team to add something to CMSMS. This was not at all my intention. As I made clear, I'm new to CMSMS and I'm merely trying to understand what's going on and what CMSMS's (im)possibilities are.
I tried to explain why I would like to use the {include} tag in an earlier post, but I'll try again. The {include} tag allows you to create modular templates. Consider it similar to any other kind of software library. It allows you to create several sub templates, which can be included in other templates, like various different page templates for instance. The sub templates need to be defined only once, instead of duplicated among several different page templates, making your page template collection easier to maintain.
We have answered your questions. We are trying to point out that there are different ways to answer the problems, if you aren't focused on one solution.
Yep, Peciura has definitely made some good suggestions. I simply didn't have the time to try them yet. My replies from today were not a response to his helpful contributions, but to the less helpful replies from Dr. CSS.
Hopefully this clears things up a bit. I hope so, because I very much appreciate what you guys are doing.
Re: Some questions regarding templates & stylesheet from a new user.
Posted: Tue Oct 27, 2009 8:35 pm
by calguy1000
3. The two questions above result from one particular issue I encountered regarding the Smarty {include} tag. Experimenting with it, I discovered that it can not be used in combination with regular templates originating from the database. From a topic in one of the Forums I understood it can be used when using regular, if placed in the [web root]/tmp/templates directory. My question is, if it is actually possible somehow to use the {include} tag in combination with regular, database originated templates.
the {include file='foo'} tag just includes a smarty template file's results into the current results. You can get the same thing with {global_content_block block='foo'} (or whatever the syntax is)... the only difference is that the GCB is stored in the database, using a smarty resource and a resource handler to extract the data from the database.
The TemplateExternalizer module uses some hooks to export page and module templates from the database into 'files' in the tmp/externalizer (by default) directory. I didn't bother to look up if it exports global content blocks or not... if it doesn't it'd be a simple modification to add that too. Once the templates are exported, you can edit the template files using your favorite text editor. Refreshing the browser page will automatically re-import the templates from the file system into the database so that your changes have immediate effect.