ONCE upon a time not so long ago, one partner wanted to display a “short description” for the product, which is totally different from the description used in the product page. There are several good reasons for that:
- By default Zencart can help you to display the first X characters, however this cannot help you to give the customers a good summary of the product (good for customers)
- Using a customized short description can let you craft your own keyword-rich description on the listing page (good for seo, if you don’t overdo it)
So I took a look around and notice there is one module that can do it:
This approach has 2 major drawbacks, however
- It is more complicated than it should be
- It is not included in search (unless you edit the search code)
So we came up with another method which is way easier than that: what if we put both the short description AND the normal description in one field, and later we split them when we display on the front end? Now there is no need for additional field and no need to edit search code.
Obviously there are multiple options for you to choose, if you want a complete solution you can use xml for example, so you can put this into your description
Then you will have to parse this xml string before you display on the front end of course.
Alternatively, you can choose to use json, etc… However, if you want to keep it as simple as possible and you don’t have many additional field anyway (just the short description for example), the perhaps this is the easiest:
You can put this in your desc:
Then on your front end, you just have to “explode” the $products_description like this:
// now $desc will contain the short description; $desc will contain the short description
Hopefully this tip will help you
No related posts.
Hello, for the XML method. How do I “parse this xml string” to display it? Any reference? Thank you.
If you have php5 +, try http://php.net/manual/en/book.simplexml.php
Thanks for the info. I will try to read the reference. As I do not know php and xml, maybe need a long time to find out what I want.
Hello, thanks a lot, now I am able to create a short description by using xml. If in my long description, there are pictures to show, how do i achieve this?
You will just simply use the image tag like normal, but please take a look at this first:
Since you will use html tags inside your xml node, you need to use cdata
Hi, thanks for all the help. I will use the easiest method first by “explode” the description, later then figure out how to use the xml method. Thanks a lot!
I am trying to apply this short description functionality to my product description. I have long product descriptions and I’m looking at either adding a “more info”feature or what you have suggested above. However, I am new to .php and zen cart and I am not sure where to ““explode” the $products_description like this”. Which file in my zen cart would I have to edit to make this work?
If you are new to it, perhaps editing the php files is something you should avoid, but anyhow the file you should edit is tpl_product_info_default.php
I’m not finding the ‘tpl_product_info_default.php’ file, am finding similar ones, such as ‘tpl_products_all_default.php’ (using Bookshelf template) and would like to modify file and implement this method, as am getting errors in the short description module, and fixing one error seems to break something else so am very hesitant to keep making changes. Could anyone please supply the complete path for the file we are to edit for the json method to work. Thank you very much.