I’ve spent nearly a month now trying to get something called Rokbox (standalone version), http://www.rockettheme.com/extensions-joomla/rokbox which is a javascript popup to work within my shopping cart, LiveCart.
I was told to make a .tpl file which I did, and I put the following in it:
I was then told to include that tpl file in the tpl file of the page I want to use Rokbox on, so I did this:
{include file="/theme/themname/rokbox.tpl"}
and proceeded normally… Problem is when I click the link, it just takes me to the URL, and doesn’t pop up the box like it’s supposed to.
What am I doing wrong here? One thing I noticed, when I do a view source, the js files aren’t included in the head section. Aren’t they supposed to be? How can I include that rokbox tpl file so that it goes in the head of the other template?
Thanks if you can help… I’ve wasted a month on this stupid thing.
(no, I don’t really have anything constructive to add, just want to add my dislike at being forced to use Smarty because apparently plain PHP templates get ‘too complicated’ -_-)
Or you could just use a CMS that allows for all sorts of template options, such as {if} statements depending on which page is being displayed. I’m doing this with ExpressionEngine at the moment and finding it amazingly flexible and powerful. What does Smarty offer that would make someone use that over a CMS?
Smarty is supposedly the reason why each of my pages can’t have a unique title, meta tags or different places for the h1… I always get told “well it’s a template so it’s easiest if every page is the same” and the indenting the spews forth from it makes me cringe “if I make a newline here it breaks”, as well as the (supposedly default? I’m told) labels added onto each <option> and other code bloat “Smarty just adds those”.
Apparently your guy just doesn’t get it. The template is the structure. As long as different pages have the same structure, the template can be re-used; just plug in different data, including data in the head like titles and whatever meta data your little heart desires. If the structure, the template, changes, it shouldn’t affect the php guy at all. All he does is provide the variables in an agreed set of key/value pairs; the front-end coder inserts those values into her structure. (There’s no reason for that structure/template not to be formatted as the coder wishes.)
@ the OP: Google for smarty templates tutorials, there’re several, and one or more will resonate for you.
Hmm, interesting. I’ll investigate Smarty some more, though it’s probably not the kind of tool that would suit my skills (or lack of them). I’ve hated every CMS I’ve looked at except ExpressionEngine, as its front end starts off completely blank. You can create your own templates, which start off as a blank sheet. So you add in all the HTML, CSS, JS, PHP etc and have complete control over it, just like in a static site.
The world. It’s not either/or. A well designed cms will use a templating engine itself. The rap against the run of the mill popular cms is that it tries to be all things to all people; so it’s a mess. That’s beside the point of having something like Smarty which allows the structure (html) to remain orthogonal to logic (PHP or your favorite server side language).
When developing even a small site, I cannot imagine trying to intermix database management, programming logic and structure. Smarty handles the mid-tier/front-end interface.
As to the cms, I’ve been lucky enough not to have had to mess with any of the big boys beyond fixing the css or other minor repairs (and that’s enough to put me off). All of my content management have been built to purpose, using Smarty, of course, and are lean and mean, rather than fat, bloated pigs.
Don’t get the idea that I’m some kind of Smarty/php guru; I’m still primarily a fixer rather than a from-scratch developer.
Mallory, Smarty templating belongs to the front-end writer, not the mid-tier PHP guy. Time to pick up a new skill set, maybe?
Hell no!?! Smarty is supposedly the reason why each of my pages can’t have a unique title, meta tags or different places for the h1… I always get told “well it’s a template so it’s easiest if every page is the same” and the indenting the spews forth from it makes me cringe “if I make a newline here it breaks”, as well as the (supposedly default? I’m told) labels added onto each <option> and other code bloat “Smarty just adds those”.
I’ve only ever ever seen PHP guys use Smarty, never front-end people. And when the guys who can make variables and changes tell me that it’s because of “how $template works” that my pages aren’t as perfect as I want them to me, and if I have more control by writing them myself by hand, then that’s how it’ll be until I get a job at some shop that knows the difference between “the chick who makes banners” and a “front ender” and actually know what the W3C is and know why it’s a total waste of money to spend tons on Google when every freaking page has the exact same header information because someone wanted to make his life easier by using a template to do all the work for him.
I realise this is a particular programmer talking to me, but that’s one reason why I have such a bias against templates. I only see them doing harm, likely because of where I work.
Smarty is a templating engine that allows for separation of programming logic from structure (html). The PHP logic exports key/value pairs, which the template plugs into the structure. The php guy doesn’t need to concern himself with the structure, and can modify the logic without having to rewrite the html too. Likewise, the front-end guy can change the structure (the Smarty template) without upsetting the logic.
Smarty is much like CSS; easy to use, more difficult to master.
Mallory, Smarty templating belongs to the front-end writer, not the mid-tier PHP guy. Time to pick up a new skill set, maybe?
Smarty is for people who regularly use PHP and want some pre-written templating for them to throw HTML together.
You don’t HAVE to use Smarty… you could do it all pure PHP. But Smarty can make things cleaner for you. My colleague uses it for just about everything. The difference is I think that he knows Smarty. I don’t know how user-friendly it is right out of the box for someone not used to it.
I did try without the literal stuff, originally, maybe I should try again, I had errors but I don’t know if they were related or not… These smarty templates seem really un-user friendly in my opinion.
Are you using Joomla? This plugin is meant to work with that, by the look of it. If not, the cart may not be recogniszing {literal}. The JS certainly does need to be linked to in the head.