[Solved]Trying to understand Smarty

The place to talk about things that are related to CMS Made simple, but don't fit anywhere else.
Post Reply
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am

[Solved]Trying to understand Smarty

Post by jasnick »

I am very familiar with CSS and HTML.

I really need to be able to understand enough Smarty to edit templates. I am trying to add my first shopping cart to a site and am looking at the various templates, Summary, Detail etc for the Products module.

I have been onto the Smarty site and looked at about 14 chapters of the Documentation. Most of which I found rather incomprehensible as it didn't seem to relate to the templates I have been looking at lately. It seemed to be mainly definitions of things with not much information on how to put it all together.

Would someone please let me know which sections of Smarty I should be looking at.

Thanks

PS - I am certainly checking this site for articles and posts on the subject but some of them are years old and I am wondering if they are still relevant.
Last edited by jasnick on Fri Dec 30, 2011 1:24 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: Trying to understand Smarty

Post by Dr.CSS »

What part of them are you trying to change, they have a bunch of templates that do different things?...
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: Trying to understand Smarty

Post by Wishbone »

Understanding Smarty syntax and structure is good, but it is also important to see which variables that the module is setting for the templates to use.

Look at the default templates and see which variables they use. There might be more available. Look at the help. Also put {get_template_vars} in your template and it will show you which variables are available.

Have you ever modified a News template? All other templates are pretty much the same, but use different variables. I usually open a stock template and remove all references I don't need. I then change the order of the references around to suit my needs and either rename the default CSS classes or keep them. This is often enough. Only if you're doing something fancy would you need to drastically re-write a template.
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am

Re: Trying to understand Smarty

Post by jasnick »

Thanks Dr.CSS and Wishbone

Yes, Wishbone, I originally did modify the News template and now usually just use the same basic one for all my sites but it was just a case of removing what I didn't want and not adding any other functionality.

What I do is copy the Sample (default) template and name it something else and work on that.

I have also done the {get_template_vars} bit and have a bit more understanding now.

I originally set up the "shop" as one page "Products For Sale" and had a product hierarchy. I have now scrapped that and set up "Products For Sale" as a Section Header and have got 3 individual pages for products. So in effect, I suppose 3 "shops".

Then for the first product, several categories and added a product to each just to see how it goes. Before I do any more, is that a better way to go than having one shop with a hierarchy?

I'd rather have someone go direct to a specific product page rather than to a summary page of ALL the different products.

Once I settle on the format I will proceed slowly and come back with any questions. I use the book CMS Made Simple 1.6 quite a lot for basic stuff and although it is not really old in terms of publishing, (2010) it is 1.6 after all so I am a bit cautious about taking everything as gospel now. There is a small section on Smarty in there so I am studying up on that.

So, one shop or a shop for each product?
Really appreciate the advice - already I am feeling more confident.

Thanks
jasnick
Power Poster
Power Poster
Posts: 695
Joined: Sat Jan 15, 2011 8:36 am

Re: Trying to understand Smarty

Post by jasnick »

Have now got the Summary template sorted and the page looks just like what I was after.
Post Reply

Return to “The Lounge”