Help a newbie install a piece of javascript with product vars on a product page
Hi all,
I'm trying to install a piece of javascript on a client's ZC store. We don't do webdev, we're a 3rd party working with them to get this installed so I don't have any experience designing/customizing Zencart stores.
This js needs to go in a specific area of the product page and needs to be installed on every product page. I'm guessing I enter this in the template product_info_display.php file? They're using theme360 if that helps. I don't know PHP very well so I'm not sure exactly where to place this.
Additionally, the js needs to have product page variables/template tags inserted into it. These vars include: brand/manufacturer, part number, price, title. Where can I find these template tags/vars? Is there a wiki or some documentation with a list somewhere?
I appreciate any and all help! I'm digging around in a lot of these php files but am really unsure where everything goes. Placement of this script is key and I dont want to break anything.
Thanks!
jhkaplan
Re: Help a newbie install a piece of javascript with product vars on a product page
It sounds like a lot of what you want to appear can be handled by standard functionality, switched on or off in various places in the admin panel.
These will not be "template" issues, because the stuff you want to appear is MOSTLY resident in the database.
But you are trying to build a Cessna out of a 747...
Just configure the admin switches and you will have all the data you need.
Additionally, "Theme360" sounds like a template monster template, and these are HUGELY PROBLEMATIC in their own right. As they are highly customised, you may struggle to get help on this forum. They can wreck core behaviour.
Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
schoolboy
It sounds like a lot of what you want to appear can be handled by standard functionality, switched on or off in various places in the admin panel.
These will not be "template" issues, because the stuff you want to appear is MOSTLY resident in the database.
But you are trying to build a Cessna out of a 747...
Just configure the admin switches and you will have all the data you need.
Additionally, "Theme360" sounds like a template monster template, and these are HUGELY PROBLEMATIC in their own right. As they are highly customised, you may struggle to get help on this forum. They can wreck core behaviour.
Thanks. Again, I'm pretty new to ZenCart, so I dont understand what you mean by 'switched on or off in various places in the admin panel.'. I need to insert the JS on product pages and update the JS with product vars so we can dynamically display an image based on a True/False statement from what the vars pass back to us.
Re: Help a newbie install a piece of javascript with product vars on a product page
Are these product variables going to change dynamically for a single product? If so, how and why would they change? If they do not change while the user is viewing the product, there is no need for javascript.
We really need more specific info before we can give accurate advice.
Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
jhkaplan
Thanks. Again, I'm pretty new to ZenCart, so I dont understand what you mean by 'switched on or off in various places in the admin panel.'.
This is an EXTREMELY GOOD REASON why you should not be fooling about with the core code. It is like a bus driver attempting heart surgery.
Before you look at very complex issues such as dynamic rendering, using JS, and possibly custom coded calls to the database, start by learning how zencart works on a user level.
It would appear that you have scant knowledge of CMS systems, because you don't seem to know that ZC operates off a database (your focus is on using JS to collect info from FILES).
I am not criticising you for your lack of knowledge, but the person you are trying to help would not be very impressed if they were in lying a hospital operating theatre, and a bus driver was wielding the scalpel.
Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
schoolboy
This is an EXTREMELY GOOD REASON why you should not be fooling about with the core code. It is like a bus driver attempting heart surgery.
Before you look at very complex issues such as dynamic rendering, using JS, and possibly custom coded calls to the database, start by learning how zencart works on a user level.
It would appear that you have scant knowledge of CMS systems, because you don't seem to know that ZC operates off a database (your focus is on using JS to collect info from FILES).
I am not criticising you for your lack of knowledge, but the person you are trying to help would not be very impressed if they were in lying a hospital operating theatre, and a bus driver was wielding the scalpel.
Maybe I'm not explaining it correctly, but most of what you said above is wrong. But if you're not here to help, please move on. I'm looking for constructive help, not to be told I dont belong.
Re: Help a newbie install a piece of javascript with product vars on a product page
Quote:
Originally Posted by
gjh42
Are these product variables going to change dynamically for a single product? If so, how and why would they change? If they do not change while the user is viewing the product, there is no need for javascript.
We really need more specific info before we can give accurate advice.
No, we're just using the js var collection to collect the product fields (ie brand, part number). Forget I said the word dynamic; something else about what the script displays is dynamic, but it's based off of the collection of the brand and part number variables. IE if brand=sony then display this image, if brand=panasonic then display this image. We're just using the collection of the brand and MPN as pieces of an equation, calculated on our end, to dynamically display an image on the product page.
The piece of the script I'm working on looks like this:
// * Product Page Fields //
'Brand' : 'XXXXX',
'MPN' : 'XXXXX',
The XXXX would be replaced by the CMS vars. In other systems I've worked with, it's something like [brand] or [manufacturer_sku]. I'm new to the Zencart world and am trying to figure out what these variables are. I'll have to work with ZC multiple times this year (as well as 10,000 other CMS's for the same type of implementation), so I'm trying to collect as much knowledge as I can to get the implementation figured out.
Thanks for your help!
Re: Help a newbie install a piece of javascript with product vars on a product page
Then please explain your needs in more detail so we can actually help you.
OK, you just did:)
Re: Help a newbie install a piece of javascript with product vars on a product page
From your description, you have no need of javascript for this. What you want will either be part of the core Zen Cart functionality (displaying a product image), available in a free addon from Plugins or require some PHP (not js) code tweaking in a file. You will enter all this product information into your admin in Catalog > Categories/Products and other places, and set admin switches in (for example) Configuration > Product Listing for the multiple product listing page and Configuration > Layout Settings for the individual product page.
Re: Help a newbie install a piece of javascript with product vars on a product page
In tpl_product_info_display.php, the variable that holds the product's model number is $products_model. The brand would be $manufacturers_name.
There will be different variable names for these in some other pages like product listing, and some pages would not have the information readily available (if the page does not handle products).