Jump to content

How insert product into a CMS page


Recommended Posts

I want insert products inside cms content (into paragraph) same of this picture (photoshop) :



 - I want have same display of product-list.tpl
 - I just would like add the desired product in a CMS page by adding a line of code with the product ID.

Can you say me what I need to do for have this modification please  :)

Edited by Denys06 (see edit history)
Link to comment
Share on other sites

it's because there is no easy solution for that. You have to modify cmsController.php, you will have to add there code to get information about product, some regular expressions to modify the cms->content variable (replace string with information about "where you want to add and what product" with product code).

it will not be as easy as it seems. If you haven't got knowledge about php, it will be much better if you will hire someone for that,

Link to comment
Share on other sites

Does this example looks like it does the trick?:




If this will do (Maybe you need to work on the layout a little), what I did is actually pretty easy:

Edit file: classes/CMS.php   (Back up file first, just in case)

and change this line: (Change red code)

public static $definition = array(
'table' => 'cms',
'primary' => 'id_cms',
'multilang' => true,
'fields' => array(
'id_cms_category' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'),
'position' => array('type' => self::TYPE_INT),
'active' => array('type' => self::TYPE_BOOL),
// Lang fields
'meta_description' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_keywords' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'size' => 255),
'meta_title' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 128),
'link_rewrite' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isLinkRewrite', 'required' => true, 'size' => 128),
'content' => array('type' => self::TYPE_NOTHING, 'lang' => true, 'validate' => 'isAnything', 'size' => 3999999999999),
and save the file.
Then comes the trick:
- use Chrome browser (Firefox can probably do similar trick, but didn't try).
- Load the category (product-list) where the product you need is listed on.
- Then right-click on the product you need and go and select "inspect Element"
- Select to the (collapsed) <li> of the product (if you have the right <li>, the product block will be shown as selected. See example image) and right-click again on this line.
- Then select "Copy as HTML"
- Go to your CMS page and click the
 icon on the menu bar to get the HTML code of the CMS page.
- find the place where you want to insert the product (maybe add ### on the page where you want to insert it, before you click the HTML icon, to find the place to insert easily) and paste the HTML code of the product in the CMS code.
- press update. If needed, edit the layout of the product a little as needed.
- Save the CMS page
- load the CMMS page in the front office and see if it works.
Hope this does the trick :-)
Link to comment
Share on other sites

Hello PascalVG, thank you for your solution.

I have do a similar modification but in HTML, into my CMS content I have put for add one product :

<table style="margin: 5px; border: 1px solid #eeeeee; border-image: none; width: 230px;">
<td colspan="2">
<h3 style="font-size: 13px; padding: 8px;"><a style="color: #000000; text-decoration: none;" href="/index.php?controller=product?id_product=311">Scalextric Digital Coffret Platinum</a></h3>
<td rowspan="3"><a style="border: 1px solid #CCCCCC; float: left; margin-right: 5px; margin: 8px;" href="/index.php?controller=product?id_product=311"><img src="/66-home_default/scalextric-digital-coffret-platinum.jpg" alt="" /></a></td>
<td><a style="font-size: 12px; color: #000000; text-decoration: none;" href="/index.php?controller=product?id_product=311"><strong>Référence</strong><br />C1276</a></td>
<td><a style="font-size: 12px; color: #000000; text-decoration: none;" href="/index.php?controller=product?id_product=311"><strong>Fabricant</strong><br />Scalextric</a></td>
<td><a style="color: #666666; font-size: 11px;" href="/index.php?controller=product?id_product=311">Le plus gros coffret jamais commercialisé par Scalextric !</a></td>
<td> </td>
<td><a style="float: right; font-size: 12px; line-height: 14px; text-shadow: none; background: url('/themes/slotcarunion/css/../img/arrow_right_1.png') no-repeat scroll 100% 4px rgba(0, 0, 0, 0); color: #0088cc; display: block; font-weight: bold; padding: 0 10px;" title="Voir" href="/index.php?controller=product?id_product=311">Voir</a></td>

I think the result is similar of your modification without edit any files ?


Now as stated Vekia, you need to do not change the name of the product, and in my example the translation does not work and I have not posted the price.

Link to comment
Share on other sites

Hi Denys,

The changes in CMS.php seemed needed in my own try out, to save the new CMS info (some tags or so weren't saved correctly, I got an error message when saving)), but if it works for you, just leave it as is.


The second part of your reply, I'm not sure what is your question... You can change in the front office in the desired language before you copy the item. Then in back office, select the same language before you paste it. It just copies the product info as shown in the product-list, so choose your language first (some layout mixes up, as the div around it is not copied). Not sure what is your question here...



Link to comment
Share on other sites

  • 10 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...