Have you ever wanted to transform a Custom Attribute from a single text line input box into a multi-line text area?
Custom Attributes 101:The Custom Attribute feature allows the customer to input additional data along with each item they purchase. This is configured in the Product Form on the 'Product Status' tab. Just type in a Label in the 'Custom Attribute List:' field and VM will display a text box on the Product Details page. You can setup multiple Custom Attributes for any product by entering a list of labels separated by a semi-colon, or ';' like so:
Name;Extras;...
Getting advaced...What if you want to replace that text box that is displayed as a single line into a multi-line Text Area so the customer can input a story along with the items purchased?
Here is one way to do this.
First, this requires a little editing of the file that is in charge of displaying the Custom Attrtibutes on the Product Details page
...
so back up your file by making a copy.This
How To was written to work with and tested on Joomla 1.0.7 and VirtueMart 1.0.2
ok, open the file:
ps_product_attribute.phplocation: <site_root>/administrator/components/com_virtuemart/classes/
find the function around line 349 called:
list_custom_attribute()find this line of code around 369:
$html .= "<input type=\"text\" class=\"inputbox\" id=\"".$titlevar."_field\" size=\"30\" name=\"$titlevar\" />";
with this one:
$html .= "<TEXTAREA rows=\"5\" cols=\"30\" id=\"".$titlevar."_field\" name=\"$titlevar\" /></textarea>";
where:
rows is the height of the text area,
cols is the width of the text area.
There are more attributes that can be used with the <textarea> tag which you can explore on your own.This will change they way VM displays the Custom Attributes... FOR ALL PRODUCTS!
Getting more advancedWell, what if I don't want all of my Custom Attributes displayed like this, you say?
You can control how Custom Attributes are displayed by adding a little logic to the above example. What I do is test what the Custom Attribute field is named, then display it as a single line textbox or a textarea accordingly.
A little planning here helps! Think of what you want for the label of your texarea Custom Attributes fields. And use that same label throughout your products when you need a TextArea field.
example:
Say you need to collect info from the customer about a product.
Choose a field label called: "
Please describe the product in as much detail as possible"
now test for that label every time a Custom Attribute needs to be displayed on Products Details pages.
take the original code line on or around line 369:
$html .= "<input type=\"text\" class=\"inputbox\" id=\"".$titlevar."_field\" size=\"30\" name=\"$titlevar\" />";
and replace it with this:
if ( $field != "Please describe the product in as much detail as possible" ) {
$html .= "<input type=\"text\" class=\"inputbox\" id=\"".$titlevar."_field\" size=\"30\" name=\"$titlevar\" />";
}
else {
$html .= "<TEXTAREA rows=\"5\" cols=\"30\" id=\"".$titlevar."_field\" name=\"$titlevar\" /></textarea>";
}
Now everytime you use "Please describe the product in as much detail as possible" as a Custom Attribute in a product, it will display that as a label along with your cool TEXTAREA.

You may need to experiment with the layout issues this will cause on the Product Details pages and the Shopping Cart and Emails and Invoices.
