markosolo Posted November 29, 2019 Share Posted November 29, 2019 Hi, Any way to use the php "include" statement in the product description area? Many products will have the same description and I would like to be able to edit them all at the same time if needed without having to edit each product description individually. I tried the standard php include but the php tag gets commented out for security reasons I'm guessing. Is there a Smarty tag perhaps that would work? Thanks! Link to comment Share on other sites More sharing options...
bsmither Posted November 29, 2019 Share Posted November 29, 2019 In a stock CubeCart, no. You may notice that when creating/editing a document, there is an option to "Parse Smarty tags". This feature can be easily ported over to creating/editing the product's description. Then, the Smarty {include} tag can be used. Would you be interested in learning how to do this? Link to comment Share on other sites More sharing options...
markosolo Posted November 29, 2019 Author Share Posted November 29, 2019 That would be great! I am already using a custom skin (copy of foundation) and am familiar with editing templates if that helps. Link to comment Share on other sites More sharing options...
bsmither Posted November 29, 2019 Share Posted November 29, 2019 This will not involve editing a storefront skin, but there will be an edit in an admin skin template. More info to follow. Link to comment Share on other sites More sharing options...
bsmither Posted November 29, 2019 Share Posted November 29, 2019 We will be making these changes: * Edit admin skin for products by adding checkbox. * Edit admin source for products by adding code to manage checkbox value. (None needed) * Edit database CubeCart_inventory by adding column to store checkbox value. * Edit Get Inventory Data to parse the product description. * Edit language file to add "Parse Smarty tags in description". catalogue group, 'smarty_parse' key In the admin template products.index.php, find: <div><label for="product_depth">{$LANG.catalogue.product_depth}</label><span><input name="product_depth" id="product_depth" class="textbox number" type="text" value="{$PRODUCT.product_depth}"></span></div> On a new blank line after, add: <div><label for="product_parse">{$LANG.catalogue.smarty_parse}</label><span><input type="hidden" name="product_parse" id="product_parse" class="toggle" value="{$PRODUCT.product_parse}"></span></div> In the file /classes/catalogue.class.php, near line 1064, find: $GLOBALS['language']->translateProduct($product); On a new blank line after, add: $product['description'] = ($product['product_parse']==1) ? $GLOBALS['smarty']->fetch('string:'.$product['description']) : $product['description']; In the file /language/definitions.xml, find: <group name="catalogue"> On a new blank line after, add: <string name="smarty_parse" introduced="6.0.0"><![CDATA[Parse Smarty Tags in Description]]></string> Using an external database utility, modify the Inventory table by executing the following. If you want to have Smarty parse the contents by default, use one (1). Otherwise, use zero (0). ALTER TABLE `CubeCart_inventory` ADD COLUMN `product_parse` TINYINT(1) UNSIGNED DEFAULT 1; If your database collection of tables uses a table prefix, be sure to prepend it to the name of the table in the statement. Bring a product up for editing, and view the General tab. If not already checked, check the box for "Parse Smarty Tags in Description". Then view the Description tab. Switch the editor to Source mode. Somewhere in the description HTML, add {"Testing"} and save the changes. Clear the cache. View the product on the storefront. The {"Testing'} is a Smarty tag that simply prints Testing. If the braces and quotes are visible, then Smarty is not parsing the content. If this is all working, then we explore how to properly use Smarty's {include} tag. Link to comment Share on other sites More sharing options...
markosolo Posted November 30, 2019 Author Share Posted November 30, 2019 Thank you for taking the time to help me with this! I will post back in a few days with the "Testing" result. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.