Welcome, Guest. Please login or register.
Login with username, password and session length


Need help or want to talk to other developers? Join the VirtueMart Chat! Read more...

  Advanced search

247038 Posts in 67506 Topics- by 258314 Members - Latest Member: aniketana
VirtueMart ForumOld Stuff, We do not support vm1.0 anymore. This boards are just for readingHow To: Tips & Tutorials VM1.0 (Moderators: deneb, guilliam)[How To] Change a Custom Attribute to display a Text Area instead of a Text Line
Pages: 1 [2]   Go Down
Print
Author Topic: [How To] Change a Custom Attribute to display a Text Area instead of a Text Line  (Read 19849 times)
Dan.Gamber
Newbie
*
Posts: 15


WWW
« Reply #15 on: August 05, 2006, 17:28:58 PM »

Have you ever wanted to transform a Custom Attribute from a single text line input box into a multi-line text area?

This meets my needs great, Deneb, thanks!  My only problem is I need the custom attribute to be an optional field.  I DON'T want an error if they leave it blank.
Logged
philraymond
Newbie
*
Posts: 6


« Reply #16 on: June 16, 2009, 12:39:59 PM »

Quote
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
« Last Edit: June 16, 2009, 14:07:14 PM by philraymond » Logged
galhal
Newbie
*
Posts: 6


« Reply #17 on: September 08, 2009, 17:14:01 PM »

hello

noone find how to made change ?
Logged
Pages: 1 [2]   Go Up
Print
Jump to: