gray Posted March 20, 2010 Share Posted March 20, 2010 Can I add 'php include' statements into description.As I need the same statement adding to many products, and I do not want to keep typing it in. Then going thru the same process if I need to change it.Any tips as I have tried or a different method, and I cannot get it to work. Link to comment Share on other sites More sharing options...
rocky Posted March 20, 2010 Share Posted March 20, 2010 According to the Smarty docs, you can use code like the following in product.tpl: {php} // including a php script directly from the template. include('/path/to/display_weather.php'); {/php} Link to comment Share on other sites More sharing options...
gray Posted March 20, 2010 Author Share Posted March 20, 2010 Yes but I was looking at putting it direct into a category or product description text box ?? Link to comment Share on other sites More sharing options...
rocky Posted March 20, 2010 Share Posted March 20, 2010 It is impossible to put PHP code in the category or product description box. You can only put HTML code in it, since it is interpreted straight in the browser and is not processed on the server. You must put your code in a PHP or TPL file.If you want to have a default description, I suggest {* commenting out *} line 329 of product.tpl: {if $features || $accessories || $HOOK_PRODUCT_TAB || $attachments} and line 384: {/if} Then change line 332 from: {if $product->description}{l s='More info'}{/if} to: {*{if $product->description}*}{l s='More info'}{*{/if}*} and add the following before line 342: {else} <!-- full description --> Put your default description here or the following to use a PHP file to generate text: {else} <!-- full description --> {php}include('/path/to/default_text.php');{/php} This will display the default description when nothing has been entered as the description for a product. If a description has been entered, it will be displayed instead of the default message. Link to comment Share on other sites More sharing options...
gray Posted March 21, 2010 Author Share Posted March 21, 2010 OK thanks, if thats the only way I can go.As I have a number of standard statements for different categories, how do I include an 'if subcategory' statement into the code.What I mean is If subcategory = shoes then include shoe text and If subcategory = socks then include sock textandIf subcategory does not need any text do not include anything Link to comment Share on other sites More sharing options...
rocky Posted March 21, 2010 Share Posted March 21, 2010 You can do that using code like the following: {if $product->id_category_default == 1}Default shoe text{elseif $product->id_category_default == 2}Default sock text{else}Default text{/if} where 1 is the ID of the shoe category and 2 is the ID of the sock category. Link to comment Share on other sites More sharing options...
gray Posted March 21, 2010 Author Share Posted March 21, 2010 That was a good quick reply.Many thanks.Presumably I can do the similar thing on the products page ie products.tplAny idea which lines of code ??The standard text should appear in the category/sub category pages, but I also need to re emphasis it on each product page but in a more abbreviated form.Just for info. The only reason I need to do this, is that certain products are only available between certain times of the year, but with no clearly defined available date of not available date. Any orders outside of the undefined dates are regarded as pre orders for the following year. But I must make this very clear to purchasers. Link to comment Share on other sites More sharing options...
rocky Posted March 21, 2010 Share Posted March 21, 2010 It is line 10 of product-list.tpl that you should change: {$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'} to something like this: {if $product.description_short}{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}{elseif $smarty.get.id_category == 1}Default shoe text{elseif $smarty.get.id_category == 2}Default sock text{else}Default text{/if} Link to comment Share on other sites More sharing options...
gray Posted March 21, 2010 Author Share Posted March 21, 2010 Many thanks. I think its going to be a good few days before I get it working. Link to comment Share on other sites More sharing options...
Recommended Posts