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.php
location: <site_root>/administrator/components/com_virtuemart/classes/
find the function around line 349 called: list_custom_attribute()
find this line of code around 369:
Code:
$html .= "<input type=\"text\" class=\"inputbox\" id=\"".$titlevar."_field\" size=\"30\" name=\"$titlevar\" />";
with this one:
Code:
$html .= "<TEXTAREA rows=\"5\" cols=\"30\" id=\"".$titlevar."_field\" name=\"$titlevar\" /></textarea>";
Is it possible to do this on VM 1.13 and Joomla 1.5? The function list_custom_attribute is now on line 794, but the $html line is no longer there and I can't figure out how to go about it.
The function now looks like this:
/**
* Creates textfields for customizable products from the custom attribute format
* @author Denie van Kleef (denievk@in2sports)
* @param unknown_type $product_id
* @return unknown
*/
function list_custom_attribute( $product_id, $prod_id = null ) {
global $mosConfig_secret ;
$db = new ps_DB( ) ;
$tpl = new $GLOBALS['VM_THEMECLASS']( ) ;
if( $product_id == 0 )
$product_id = $prod_id ;
$q = "SELECT product_id, custom_attribute from #__{vm}_product WHERE product_id='$product_id'" ;
$db->query( $q ) ;
$db->next_record() ;
$custom_attr_list = $db->f( "custom_attribute" ) ;
if( $custom_attr_list ) {
$has_custom_attributes = 1 ;
$fields = explode( ";", $custom_attr_list ) ;
$html = "" ;
$prod_index = $product_id ;
if( $prod_id ) {
$prod_index = $prod_id ;
}
$attributes = array( ) ;
$i = 0 ;
foreach( $fields as $field ) {
$titlevar = str_replace( " ", "_", $field ) ;
$title = ucfirst( $field ) ;
$attributes[$i]['product_id'] = $prod_index ;
$attributes[$i]['title'] = $title ;
$attributes[$i]['titlevar'] = $titlevar ;
$i ++ ;
}
}
if( $custom_attr_list ) {
$tpl->set( 'attributes', $attributes ) ;
$tpl->set( 'mosConfig_secret', $mosConfig_secret ) ;
return $tpl->fetch( 'product_details/includes/addtocart_custom_attribute.tpl.php' ) ;
}
}
Edit: I figured it out. The change is now made in product_details/includes/addtocart_custom_attribute.tpl.php.
Thanks very much,
Phil