![]() |
PHP and Smarty coding mods for newbie???
Hi,
My 1st store is working but nowhere near live yet. I'm just getting the feel for the template system and understand that there is PHP coding within the HTML and that CSS and HTML can be modified just like any other web site. My question; is how to change some of the PHP (and Smarty?) coding? Really, how to even find it? I'm not talking about programing in PHP, simply changing some simple wording. Specifically: In top_menu.tpl, line 23 is this: Code:
{if $config.Company.company_phone}{$lng.lbl_phone_1_title}: {$config.Company.company_phone}{/if}{if $config.Company.company_phone_2} {$lng.lbl_phone_2_title}: {$config.Company.company_phone_2}{/if} </td> That adds the "CALL US: 555.555.5555" to the header. We want to reword that to something like: If you need assitance call us at: 555.555.5555 The change has nothing to do with functionality, just verbiage, so where/how do I make that change (and similar types of changes)? Thanks guys! :-) |
Re: PHP and Smarty coding mods for newbie???
Ok, it isn't PHP, it is Smarty and all of it can be controlled one of two ways:
1. Webmaster Mode - read about this in the manual, it will be your best friend. 2. In the 'Languages' area of the admin - also covered pretty well in the manual. It looks much more complicated than it really is, you will never have to actually edit the text in the templates, it is all in the database and is controlled via Webmaster mode or the Languages area. |
Re: PHP and Smarty coding mods for newbie???
Or at times the general settings -> company options section, or in the payment configuration section, or some deeply buried section that will simply take time, effort and possibly forum research to locate ;)
|
Re: PHP and Smarty coding mods for newbie???
Quote:
OK... so you're saying that when I click "Open customer area in a new window", in webmaster mode, the list of "Included templates & config files" are all I need to work with to change or reformat the design/layout, basic functions of the site? Thanks guys! |
Re: PHP and Smarty coding mods for newbie???
No, webmaster mode will just let you change the text and let you know which template is which. To actually change layout, graphics and color, you have to edit the html in the templates, and the styles in the master stylesheet.
|
Re: PHP and Smarty coding mods for newbie???
Going back to my example in my original post... I cannot find anything for the text "CALL US..." in the customer/top_menu.tpl template except the code I originally posted. I still don't understand then how I can reword that. :( Can you explain?
Thanks! |
Re: PHP and Smarty coding mods for newbie???
Yea, you aren't getting what I'm saying. Open the site in webmaster mode. Click on that text, you can edit it right there.
|
Re: PHP and Smarty coding mods for newbie???
I do understand what you're saying... I just don't see the text. Either I'm blind to it or it's part of the code. If you have a moment, please look at the file in your store and let me know if I need to see the optometrist or not. :cry:
Thanks a lot! |
Re: PHP and Smarty coding mods for newbie???
Hi Spia,
You have used webmaster correctly and found the code which corresponds to the text you want to change. I am about to sleep - so quick reply without checking. Assuming your code example is correct, then it is telling me that smarty language variable holds the text "CALL US:" is "lbl_phone_1_title" (note: the lng. in front of this is telling smarty to use the current language version of this smarty variable e.g. if someone was in French on your store they would get the French version of the language variable "lbl_phone_1_title" and not the English one - just explaining the meaning of "lng." for you). The easiest way is to change the text for this language variable "lbl_phone_1_title". So in X-Cart Admin open the "Administration" -> "Languages" page and choose "English" for the selected language. This will then reload the page and show a list of all the smarty language variables used for English within your store (there are around 5000 for customer and admin side - so do not go page to page to search for this). In the search box (find) put in "lbl_phone_1_title" (without quotes obviously) and click to search for this variable (you could also put in "CALL US" - but that might not show just one language variable - so "lbl_phone_1_title" is best idea). Manually change the text in the box for this field "lbl_phone_1_title", to read "If you need assistance call us at" (note the colon ":" is not needed in the text in this box, as it appears in the template code example you showed above). Then click the save (update) button. Refresh your homepage in your browser and you should see the changed text appear. If it does not appear - clear your browser cache (e.g. Tools, Clear Private Data in Firefox browser) and try to view again... Hope this helps - cheers, Asiaplay PS: an alternative method is to add a new language variable in X-Cart languages (e.g. "lbl_phone_1_title_custom4me" and change the template line to use that - however I wouldn't bother adding a language variable in this case and changing the template (as no need for a simple change like this)... and would just change the text of the present "lbl_phone_1_title" being used (i.e. change standard X-Cart text as suggested above). |
Re: PHP and Smarty coding mods for newbie???
Great advice - Thank You! At least I don't need to see the optometrist...
A few more questions: How difficult is it to add new language variables and where does that go? Is that a Smarty thing and does that require PHP or Smarty coding skills as well? There seems to be a massive learning curve to create a graphically (not so much functionally) custom site. Am I right about this because it is discouraging? |
Re: PHP and Smarty coding mods for newbie???
You can add new language variables in the same area mentioned above - the languages area. Really should take a look at the manual on this one, it covers the whole webmaster mode/language variable thing pretty well, as that is a core function of this software.
|
Re: PHP and Smarty coding mods for newbie???
Spia,
Happy you managed to change the text you wanted to - progress :) My guess is 60 to 80% of users start using X-Cart with only basic html (and maybe CSS) understanding or no programming knowledge (so it can be used by non-programmers for sure). Adding text in smarty is easy (and is not coding based to add the text value or variable) - as Balinor says - read the manual on this (basically at the bottom of the languages page in X-Cart Admin, you just add in a variable, using a variable name which has not been used before ). To know what has not been used you could export a language and import it into MS Excel (see Internationalization section for importing and exporting a language e.g. Russian language post answer I provided in there) or reading the manual. The 2nd step is to add the newly created language variable, into a template (or change an existing variable named in a template to match the new one you have just made) is coding based. At the start you are better off to change the text in a box for existing language variables (rather than add too many new ones) - slowly learn. Your question... "Is there a big learning curve" - there is some if you have never used html before - yes (but you are 80% there understanding how to use webmaster mode). Things are easier if you understand basic html programming and then change the syntax a little for it to be php - what I would do initially if I was you is follow mods others in the forum have done (you will then begin to understand how php code works). For changing text on a page - 95% of the time this can be done within the X-Cart languages section of X-Cart Admin. If you do not understand basic smarty code (used mainly for languages) or php code then changing things can take time or be hard (if you do not understand basic html first) - yes... there is a learning curve. But it is not really, really difficult really - as php like html does use pretty easy to read logic (unlike many other programming languages) and the layout is based on html table code a lot. However the advantage is almost anything can be changed (unlike other carts where code is locked). Lastly - there are some changes which are harder - logical changes to things like cart $ values or shipping (as these are not a simple change to one template - sometimes this can mean a change in several templates and quite complex logical maths code... not impossible - but harder than layout changes and probably better to avoid unless a custom mod had been provided in the forum which another user has said works). So layout, colours and text is easier (but function is harder). At the start - the easiest and fastest way to change colour and text is to buy a custom skin - one which is close to how you want the cart to finally appear - see www.dana7.com or http://x-cart-customization.com/shop/ (then change this custom template to match what you want). Remember that many layout changes are also made in the CSS file (once again quiet easy to do once you try) - e.g. text size For function changes, for now I suggest stick to completed mods available in the forum or bought ones (and learn from doing those first). Hope comments help - cheers, Asiaplay PS: trick is to keep a back-up copy of the original before you make a change - so if you mess up the mod instructions (then you can replace the messed up changed template or page with the original you backed up... then at least you have not lost anything, but a little time). |
Re: PHP and Smarty coding mods for newbie???
Thanks so much for the detailed and helpful information! I have a feel for it now, but just wanted to understand how much deeper I have to go to see real results.
I know HTML fairly well and CSS to a lesser but workable degree. I've even coded a few test PHP "Hello world" pages. I work with a graphic person that is used to designing any layout she wants (within reason) and then I have to figure out how to make that work in HTML. Years of working together that way have made us averse to using other people's templates (we've never done it). That's why I want to be sure that I can move stuff around, change textual content, delete things we don't want, etc. Just changing a color scheme would never fly. I've been reading (pieces of) the manual - ther's just soooooooooooooo much manual... 8O |
Re: PHP and Smarty coding mods for newbie???
Try this as well, it will give you a good handle on the templates:
http://forum.x-cart.com/showthread.php?t=21529 |
Re: PHP and Smarty coding mods for newbie???
Thanks. I read it quickly but will go back and read it carefully later as I check out more of the manual too...
One more quick question: If I want to use the content of something like customer/categories.tpl in a brand new scratch built HTML page of my making, how do I do that so that it generates the needed content in my page? |
Re: PHP and Smarty coding mods for newbie???
That really isn't an easy task - your best bet is to use the embedded static pages to create all of your non-cart pages - they show up in the main area and have the rest of the site wrapped around them.
|
Re: PHP and Smarty coding mods for newbie???
Uggh! That sounds like the deal killer. Am I to understand that most people using X-cart just go with the stock layout or generic templates and just do color adjustments and just a few design tweaks? Does anyone have original designs that they fit X-cart to rather than the other way around?
Quote:
What do you mean exactly by main area? And if I still want to take on this difficult task, can you direct me to where I can learn about doing it? Thanks! |
Re: PHP and Smarty coding mods for newbie???
Not at all. Most people add their own designs to X-Cart - once you get the hang of it it is easier than you think. There is one set of templates so you edit them once and then every new page you create automatically uses the design. Add a new embedded static page and you'll see what I mean.
You can either buy a pre-made template from someplace like 7dana.com, or you can completely customize the look and feel to what you want. The pre-made templates are obviously easier, but a custom design is really the way to go if you want to get noticed. |
Re: PHP and Smarty coding mods for newbie???
You've been a big help, but please give me a better handle on this.
If you wanted to "embed" or "integrate" X-cart into a section on the ryandesignstudio.com site or one of your clients like pointonearchitects.com, without breaking the existing design or looking like an aftermarket cart system was an aftertought to a custom designed site, how would you do it? Thanks! |
Re: PHP and Smarty coding mods for newbie???
I'm pretty sure you would be killing yourself to try to integrate x-cart into a totally external design. From what I've seen x-cart is a standalone app that you need to design inside of for it to fully function. Someone else can correct me if I'm wrong but I think you do what you are talking about with Lite Commerce.
|
Re: PHP and Smarty coding mods for newbie???
Correct, you need to integrate your design INTO X-Cart, not the other way around. X-Cart works best AS the site - which is why you don't want external html files, they all should be inside x-carts structure.
|
Re: PHP and Smarty coding mods for newbie???
Like I thought - that's the deal killer. Anyone know what the real functional/feature difference is for Lite Commerce? (not clear to me from the web site)
|
Re: PHP and Smarty coding mods for newbie???
Same thing - it isn't really meant to be added to an existing site, but function AS the site.
|
All times are GMT -8. The time now is 05:11 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.