Jump to content
thirty bees forum

How to add an extra textarea/field on product page


zimmer-media

Recommended Posts

step 1 Add an entry to the database in the table prefixproductlang (for example name - what you need)

0_1514162327849_7edf3844-a6f7-4626-acf7-48a78fea68f1-grafik.png

step 2.1 modify the file “Product.php” from “/classes/Product.php”, preferably in the folder classes Override “/override/classes/Product.php” save see the lines

/** @var string Long description */ public $description; /** @var string Short description */ public $description_short; just add the following /** @var string Extra Field */ public $extra_field; step 2.2 for example find

'name' => ['type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isCatalogName', 'required' => true, 'size' => 128], 'description' => ['type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'], after this insert 'extra_field' => ['type' => self::TYPE_HTML, 'lang' => true, 'validate' => 'isCleanHtml'], step 3 copy your informations.tpl under override / controllers / admin / templates / products / informations.tpl for example and find the code (depending on where this additional field should appear.) <div class="form-group"> <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="description" type="tinymce" multilang="true"}</span></div> <label class="control-label col-lg-2" for="description_{$id_lang}"> <span class="label-tooltip" data-toggle="tooltip" title="{l s='Appears in the body of the product page.'}"> {l s='Description'} </span> </label> <div class="col-lg-9"> {include file="controllers/products/textarea_lang.tpl" languages=$languages input_name='description' class="autoload_rte" input_value=$product->description} </div> </div> after this insert <div class="form-group"> <div class="col-lg-1"><span class="pull-right">{include file="controllers/products/multishop/checkbox.tpl" field="extra_field" type="tinymce" multilang="true"}</span></div> <label class="control-label col-lg-2" for="extra_field_{$id_lang}"> <span class="label-tooltip" data-toggle="tooltip" title="{l s='Appears in the body of the product page.'}"> {l s='Extrafield'} </span> </label> <div class="col-lg-9"> {include file="controllers/products/textarea_lang.tpl" languages=$languages input_name='extra_field' class="autoload_rte" input_value=$product->extra_field} </div> </div> step 4 if you want to see this field in your frontoffice product view - in your theme product.tpl add the follow code with in your tpl ( for example default theme)

find {if isset($product) && $product->description} <section id="product-description" class="page-product-box"> <h3 class="page-product-heading">{l s='More info'}</h3> <div class="rte">{$product->description}</div> </section> {/if} insert after this {if isset($product) && $product->extra_field} <section id="extra_field" class="page-product-box"> <h3 class="page-product-heading">{l s='Extrafield'}</h3> <div class="rte">{$product->extra_field}</div> </section> {/if} backoffice product page 0_1514166048020_49b10b4d-a0e6-455f-88d7-19ff2c6e04dc-grafik.png

frontoffice product page new

0_1514165019955_987354bd-c78e-4a42-b75c-42200ad09ae8-grafik.png

Link to comment
Share on other sites

Of course, more than one text box can be added as needed to customize the data (change all "extra_field"). It is important in the product.tpl the title of the text field

{ls = 'Extrafield'} </ h3> for the front view and in the informations.tpl the name of your textarea { ls = 'Extrafield'} correctly, so that you do not confuse this when entering.

In the front view, the text areas are only displayed if data has been saved in the field.

Link to comment
Share on other sites

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...