Author Topic: Increasing Custom Field Default Value Maximum Characters? Is it possible?  (Read 12755 times)

vnj20041

  • Beginner
  • *
  • Posts: 3
hello,

I'm trying to add attributes for products.  since im working on Joomla 2.5 and VM2 , Im dealing with custom fields., So I created the custom field and in the "default" area, typed all the type of item options separated by a colon.  However, after typing about 10 item options, it wont let me enter any more., Is there a way for me to increase these max character lenght? if so, how?  please advice.

thanks,

gboul

  • Beginner
  • *
  • Posts: 16
We thought two ways to address this issue. The simple one is to change the length of the field using a tool like phpadmin and possibly the definition of that field in the code.
In the one that we implemented, first we created a table to hold all the distinct values of all custom fields. Done that we searched the code and we found that all is needed is to change one function in the model customfield.php (inputtype if i am not mistaken) to read the corresponding values from the table instead from the default field.
Hope this helps you.

vnj20041

  • Beginner
  • *
  • Posts: 3
We thought two ways to address this issue. The simple one is to change the length of the field using a tool like phpadmin and possibly the definition of that field in the code.
In the one that we implemented, first we created a table to hold all the distinct values of all custom fields. Done that we searched the code and we found that all is needed is to change one function in the model customfield.php (inputtype if i am not mistaken) to read the corresponding values from the table instead from the default field.
Hope this helps you.

Gboul., Thank you for responding., I appreciate your help.   Looks like you have a good understanding of what I'm trying to do., Can you please detail me to go about increasing the characters in PHPMyAdmin? I changed the "Custom Value" CHAR field from 255 to 955 and it gives me an error stating that the column is too big.  I also tried looking for customfield.php but I cannot find that file? can you please point me in the right direction and maybe include some step by step process to increase the character length in custom field default value ? thanks.

notanothernumber

  • Jr. Member
  • **
  • Posts: 56
Hi vnj I'm with you on this. I'm building a record store site and need to use a custom field to show the genre of music. This is the full list:

12-INCH/MAXI SINGLES;5-INCH CD SINGLES;5-INCH COMPACT DISC VIDEO (CDV);7-INCH/CASSINGLES;8-INCH LASERDISC;ACCESSORIES;ACCORDION;ACID JAZZ;ACTION / ADVENTURE;ACTION / ADVENTURE (VIDEO GAME);ACTION-MARTIAL ARTS;ADULT;ADULT ENTERTAINMENT;ADULT-HARDCORE;AFRICAN;ALBANIAN;ALGERIAN;ALT-COUNTRY & AMERICANA;ALTERNATIVE LIFESTYLE;ALTERNATIVE ROCK;ALTERNATIVE-GAY;AMBIENT;ANDEAN;ANGOLAN;ANIMATION;ANIME-CHILDREN;ANIME-EROTIC;ANIME-JAPANESE;ARABIC;ARGENTINEAN;ARMENIAN;ASIAN;AUSTRALIAN;AZERBAIJANI;BACHATA;BALINESE;BALLET VIDEO;BANDA;BANJO;BASS;BAVARIAN;BELGIAN;BELLY DANCING;BIG BAND;BLUEGRASS;BLUES;BLUES TRADITIONAL;BLU-RAY;BOLERO;BOLIVIAN;BOOKS ON TAPE/CD;BOX SETS;BRAZILIAN;BRITISH;BRITISH-ACTION & ADVENTURE;BRITISH-COMEDY;BRITISH-DRAMA;BRITISH-MYSTERY;BRITISH-SCI-FI & HORROR;BRITPOP;BULGARIAN;BURMESE;CAJUN;CALENDARS;CALYPSO;CAMBODIAN;CAMEROON;CANADIAN;CAPE VERDE;CARIBBEAN;CAST RECORDINGS;CD-ROM;CELTIC;CENTRAL AMERICAN;CHILDREN'S;CHILDREN'S LASERDISC;CHILDREN'S VIDEO;CHILDREN'S/EDUCATIONAL (VIDEO GAME);CHILEAN;CHINESE;CHRISTIAN;CHRISTIAN COUNTRY;CHRISTIAN RAP;CHRISTIAN ROCK;CLASSICAL ARTISTS;CLASSICAL CAST CROSSOVER;CLASSICAL COMPOSERS;CLASSICAL CROSSOVER;CLASSICAL SOUNDTRACK/SCORE;CLASSICAL VIDEO;CLASSICAL VOCAL CROSSOVER;CLASSICS;CLASSICS-SILENT FILMS;COLUMBIAN;COMEDY;COMEDY VIDEO;COMEDY-CLASSIC;COMEDY-CONTEMPORARY;COMEDY-ROMANTIC COMEDY;COMEDY-STAND-UP COMEDY;CONGOLESE;CORSICAN;COUNTRY;COUNTRY TRADITIONAL;CROONERS;CUBAN;CULT;CULT-EROTICA;CULT-WOMEN IN PRISON;CZECH;DANCE;DEFAULT;DISCO;DOWN TEMPO;DRAMA;DRAMA-HISTORICAL DRAMA;DRAMA-INDIE & ARTHOUSE CINEMA;DRAMA-ROMANTIC DRAMA;DRUM & BASS;DUTCH;DVD AUDIO;DVD SINGLE;DVD-ROM;EASY LISTENING;EDUCATIONAL;EGYPTIAN;ELECTRONIC;ENGLISH;ENHANCED CD;ENVIRONMENTAL;ETHIOPIAN;EXERCISE;EXPERIMENTAL (NOISE);FAMILY;FAMILY-ANIMATED;FAMILY-DISNEY;FAMILY-LIVE ACTION;FAMILY-PBS KIDS;FAMILY-SESAME STREET;FIDDLE;FIGHTING (VIDEO GAME);FINNISH;FLIGHT SIMULATOR (VIDEO GAME);FOLK;FOREIGN;FOREIGN-CHINESE;FOREIGN-FRENCH;FOREIGN-GERMAN;FOREIGN-INDIAN;FOREIGN-ISRAELI;FOREIGN-ITALIAN;FOREIGN-JAPANESE;FOREIGN-KOREAN;FOREIGN-SPANISH;FOREIGN-SWEDISH;FRENCH;GABON;GAMES;GERMAN;GO GO;GO GO COLLECTIONS;GOSPEL;GREEK;GUINEAN;GYPSY;HAITIAN;HALLOWEEN;HANUKKA;HAWAIIAN;HD DVD;HEALTH & FITNESS;HEALTH & FITNESS-DANCE FITNESS;HEALTH & FITNESS-DIET & NUTRTN;HEALTH & FITNESS-KICKBOXING;HEALTH & FITNESS-PILATES;HEALTH & FITNESS-PREGNANCY;HEALTH & FITNESS-TAI-CHI;HEALTH & FITNESS-YOGA;HEAVY METAL;HISTORICAL;HOLIDAY-CHRISTMAS (ANIMATED);HOLIDAY-CHRISTMAS (LIVE ACTION;HORROR;HORROR-ASIAN HORROR;HORROR-GHOSTS & SUPERNATURAL;HORROR-MONSTERS;HORROR-SLASHERS;HOUSE;HUNGARIAN;INDIAN;INDIE ROCK/POP;INDONESIAN;INDUSTRIAL/GOTHIC;INDY PROMOTION ONLY;INSTRUCTIONAL;INSTRUMENTAL;INTERNATIONAL;IRANIAN;IRAQI;IRISH;ISRAELI;ITALIAN;IVORY COAST;JAPANESE;JAVANESE;JAZZ;JAZZ TRADITIONAL;JAZZ VOCALS;JEWISH;KARAOKE;KARAOKE VIDEO;KENYAN;KOREAN;KURDISTAN;LANGUAGE;LASERDISC;LATIN DANCE;LATIN IMPORTS;LATIN INSTRUMENTAL;LATIN JAZZ;LATIN JAZZ VOCALS;LATIN POP/ROCK;LATIN RAP;LATIN VOCAL;LOUNGE/EXOTICA;MADAGASCARIAN;MAGAZINES / BOOKS;MALI;MARCHES (POP);MARCHES/MARCH COLLECTIONS;MARIACHI;MEDITATION;MEN'S MUSIC;MIDDLE EAST;MIDNIGHT MOVIES (UNDERGROUND);MINI-DVD;MISCELLANEOUS;MISCELLANEOUS NON-MUSIC VIDEO;MONGOLIAN;MOROCCAN;MOTION PICTURE VIDEO;MOZAMBIQUE;MUSIC VIDEO (CONCERT/PERFORMANCE);MUSICAL;MUSICALS (THEATRICAL);MYSTERY / SUSPENSE;NATIVE AMERICAN;NEW AGE;NEW GUINEAN;NEW ZEALAND;NIGERIAN;NORTENO;NORWEGIAN;NOSTALGIA;NOSTALGIA-SPOKEN;NU-JAZZ;OLDIES;OPERA/OPERETTA;PAKISTANI;PERSIAN;PERUVIAN;PLAYS;POETRY;POLISH;POLKA;POLYNESIAN;PORTUGUESE;POWER POP;PSYCHEDELIC/GARAGE;PUERTO RICAN;PUNK;RACING / DRIVING (VIDEO GAME);RAGTIME;RAI;RAP/HIP HOP;REGGAE;REGGAETON;REGIONAL MEXICAN;RELIGION;RELIGIOUS-CONTEMPORARY;RELIGIOUS-DOCUMENTARIES;ROCK/POP;ROCKABILLY;ROLE PLAYING (VIDEO GAME);ROMANIAN;RUSSIAN;SALSA/MERENGE;SAMPLER;SCIENCE FICTION;SCI-FI-CLASSIC;SCI-FI-CONTEMPORARY;SCOTTISH;SCREWED & CHOPPED;SEASONAL;SELF HELP;SENEGALESE;SERBIAN;SHIPPER FREIGHT FEES;SHOOTER (VIDEO GAME);SIMULATION (VIDEO GAME);SINGER/SONGWRITER;SKA;SOCA;SOUL/R & B;SOUL-JAZZ & BOOGALOO;SOUND EFFECTS;SOUNDTRACK;SOUTH AFRICAN;SOUTH AMERICAN!;SOUTHERN GOSPEL;SOUTHERN ROCK;SPANISH;SPECIAL INTEREST;SPECIAL INTEREST-ART;SPECIAL INTEREST-DOCUMENTARY;SPECIAL INTEREST-EDUCATIONAL;SPECIAL INTEREST-INSTRUCTIONAL;SPECIAL INTEREST-NATURE;SPECIAL INTEREST-TRAVEL;SPECIAL INTEREST-US HISTORY;SPECIAL INTEREST-WAR;SPECIAL INTEREST-WORLD HISTORY;SPOKEN;SPORTS;SPORTS (VIDEO GAME);SPORTS-BASEBALL;SPORTS-BASKETBALL;SPORTS-FOOTBALL;SPORTS-SOCCER;SPORTS-WRESTLING / MMA;STRATEGY / PUZZLE (VIDEO GAME);STRING BAND;SURF;SUSPENSE-FILM NOIR;SWEDISH;SWISS;SYRIAN;TAHITIAN;TANGO;TANZANIAN;TECHNO;TEJANO;TELEVISION;TELEVISION SOUNDTRACK;TEST RECORDS;THAI;TIBETIAN;TRIP HOP;TROPICAL;TURKISH;TV ACTION & ADVENTURE;TV ANIMATION;TV ANTHOLOGIES;TV COMEDY;TV CRIME;TV DRAMA;TV FAMILY;TV HORROR;TV MEDICAL DRAMA;TV MINI-SERIES;TV REALITY;TV SCI-FI;TV VARIETY & MISC;TV WESTERN;TYROLEAN;UKRAINIAN;UMD;VENEZUELAN;VIDEO GAME;VIDEO GAME ACCESSORIES;VIDEO GAME SOUNDTRACK;VIETNAMESE;VOCAL;WAR;WAR DRAMA;WAR-AFGHANISTAN & IRAQ;WAR-KOREAN WAR;WAR-VIETNAM WAR;WAR-WORLD WAR II;WEDDING MUSIC;WELSH;WESTERN;WESTERNS;WESTERNS-CLASSICS;WESTERNS-CONTEMPORARY;WOMEN'S MUSIC;WORLD BEAT;WORLD DANCE;XMAS CHILDRENS;XMAS CLASSICAL INSTRUMENTAL;XMAS CLASSICAL VOCAL;XMAS INSTRUMENTAL;XMAS INTERNATIONAL;XMAS SINGLES;XMAS VIDEO;XMAS VOCAL;YIDDISH;YUGOSLAVIAN;ZYDECO;


But presently only displays up to here:

12-INCH/MAXI SINGLES;5-INCH CD SINGLES;5-INCH COMPACT DISC VIDEO (CDV);7-INCH/CASSINGLES;8-INCH LASERDISC;ACCESSORIES;ACCORDION;ACID JAZZ;ACTION / ADVENTURE;ACTION / ADVENTURE (VIDEO GAME);ACTION-MARTIAL ARTS;ADULT;ADULT ENTERTAINMENT;ADULT-HARDCORE;AFRIC

Which I've worked out is 255 characters when I need it to contain approx 6000!!! Anyone any ideas on how to work around this??

Cheers Martin

gboul

  • Beginner
  • *
  • Posts: 16
The simple solution is to increase the size of the corresponding field in the table.
I am not sure how big it can get, but you can try to increase it to 6000-10000 characters.
But in our case we implemented two new tables one to hold the custom keys and one to hold the custom values.
Of course we had to change a couple files to accommodate these tables.
If you want this, I am more than happy to post the changes.

notanothernumber

  • Jr. Member
  • **
  • Posts: 56
Thanks gboul any step by step instructions on how you did this would be mightily appreciated

Cheers
Martin

ivus

  • Full Member
  • ***
  • Posts: 534
  • - YAY me... proud member of the 500 club...
Hi everyone,

it's not really as simple as that. If you increase the field limit in the database, the form field limit on the page will still stop you at 255 characters. So you'll need to do both if you want to achieve this.


Using PHPMyAdmin, find the table #__virtuemart_customs and edit the structure of the table.

All you need to do is change the custom_value from

Code: [Select]

`custom_value` char(255) COMMENT 'defaut value',


to

Code: [Select]

`custom_value` text COMMENT 'defaut value',


This will allow much more data to be stored.

The second part is to remove the maxlength limit on the field... but what would be better is to change the field type so you have more room to enter all your values...

Open this file "\administrator\components\com_virtuemart\models\customfields.php" and alter the code on line 293

from:

Code: [Select]

  $html .= VmHTML::row ('input', 'COM_VIRTUEMART_DEFAULT', 'custom_value', $datas->custom_value);


to:

Code: [Select]

  $html .= VmHTML::row ('textarea', 'COM_VIRTUEMART_DEFAULT', 'custom_value', $datas->custom_value);


Obvious this will only work until the VM does an update as your code will get over written..

I hope this helps.

gboul

  • Beginner
  • *
  • Posts: 16
Our solutions was to change the function inputType in the models/customfields.php
Code: [Select]
public function inputType($field,$product_id,$row){

$field->custom_value = empty($field->custom_value) ? $field->value : $field->custom_value ;

if ($field->is_cart_attribute)  $priceInput = '<input type="text" value="'.(isset($field->custom_price)?$field->custom_price: '0').'" name="field['.$row.'][custom_price]" />';
else $priceInput = ' ';

if ($field->is_list) {
//Start of our change
$values=array();
if($field->custom_value!=''){
$values = explode(';',$field->custom_value);

}else{
$tmp=$this->getValues($field->virtuemart_custom_id);
foreach($tmp as $tm){
foreach($tm as $t){
array_push($values, $t);
}
}
}
//End of our changee... the code follows as normal

And we added a new function the getValues which get the values of a custom id from a new table that we have created to store them there
Code: [Select]
public function getValues($virtuemart_custom_id){

$db = JFactory::getDBO();
$db->setQuery('SELECT  `custom_value` FROM `#__virtuemart_customs_values` WHERE custom_id='.$virtuemart_custom_id);
return $db->loadRowList();
}

This solution is not for the beginner and any virtuemart upadtes will overwrite this file.

hope it provides food of thought...

yayo76

  • Beginner
  • *
  • Posts: 23
Our solutions was to change the function inputType in the models/customfields.php
Code: [Select]
public function inputType($field,$product_id,$row){

$field->custom_value = empty($field->custom_value) ? $field->value : $field->custom_value ;

if ($field->is_cart_attribute)  $priceInput = '<input type="text" value="'.(isset($field->custom_price)?$field->custom_price: '0').'" name="field['.$row.'][custom_price]" />';
else $priceInput = ' ';

if ($field->is_list) {
//Start of our change
$values=array();
if($field->custom_value!=''){
$values = explode(';',$field->custom_value);

}else{
$tmp=$this->getValues($field->virtuemart_custom_id);
foreach($tmp as $tm){
foreach($tm as $t){
array_push($values, $t);
}
}
}
//End of our changee... the code follows as normal

And we added a new function the getValues which get the values of a custom id from a new table that we have created to store them there
Code: [Select]
public function getValues($virtuemart_custom_id){

$db = JFactory::getDBO();
$db->setQuery('SELECT  `custom_value` FROM `#__virtuemart_customs_values` WHERE custom_id='.$virtuemart_custom_id);
return $db->loadRowList();
}

This solution is not for the beginner and any virtuemart upadtes will overwrite this file.

hope it provides food of thought...

Hi,
I must replace or add the code? Can you to pubblish the modified file?
Thank you

gboul

  • Beginner
  • *
  • Posts: 16
I can not give you the whole file since it is quite long file and also contains changes that are not relative to this post. Sorry that I can not provide step to step directions as well.
I just gave the rough idea of the implementation that we followed.
Our solution requires to add new tables (with phpmyadmin) where the custom id along with the custom values are stored.

olaand

  • Beginner
  • *
  • Posts: 9
Hi everyone,

it's not really as simple as that. If you increase the field limit in the database, the form field limit on the page will still stop you at 255 characters. So you'll need to do both if you want to achieve this.


Using PHPMyAdmin, find the table #__virtuemart_customs and edit the structure of the table.

All you need to do is change the custom_value from

Code: [Select]

`custom_value` char(255) COMMENT 'defaut value',


to

Code: [Select]

`custom_value` text COMMENT 'defaut value',


This will allow much more data to be stored.

The second part is to remove the maxlength limit on the field... but what would be better is to change the field type so you have more room to enter all your values...

Open this file "\administrator\components\com_virtuemart\models\customfields.php" and alter the code on line 293

from:

Code: [Select]

  $html .= VmHTML::row ('input', 'COM_VIRTUEMART_DEFAULT', 'custom_value', $datas->custom_value);


to:

Code: [Select]

  $html .= VmHTML::row ('textarea', 'COM_VIRTUEMART_DEFAULT', 'custom_value', $datas->custom_value);


Obvious this will only work until the VM does an update as your code will get over written..

I hope this helps.

This was great help and helped be to add many more options to the custom field. However, suddenly VM seem to have reverted the db field back to the 255 limited for the custom field without me updating VM. Would VM update db automatically?

Maxim Pishnyak

  • Global Moderator
  • Sr. Member
  • *
  • Posts: 2658
Don't understand you clearly.

VM Team doesn't support hacks, so you need to take care about your changes in db BEFORE you're going to update VM.

Apply update, and restore your db changes then.

It's could be useful to know what update of current VM version is going to do with db (your case).

CreativeDesigns

  • Jr. Member
  • **
  • Posts: 219
    • Creative Designs Studio
  • Skype Name: creative.designs.za
Re: Increasing Custom Field Default Value Maximum Characters? Is it possible?
« Reply #12 on: December 03, 2013, 19:37:27 pm »
Hi everyone,

it's not really as simple as that. If you increase the field limit in the database, the form field limit on the page will still stop you at 255 characters. So you'll need to do both if you want to achieve this.


Using PHPMyAdmin, find the table #__virtuemart_customs and edit the structure of the table.

All you need to do is change the custom_value from

Code: [Select]

`custom_value` char(255) COMMENT 'defaut value',


to

Code: [Select]

`custom_value` text COMMENT 'defaut value',


This will allow much more data to be stored.

The second part is to remove the maxlength limit on the field... but what would be better is to change the field type so you have more room to enter all your values...

Open this file "\administrator\components\com_virtuemart\models\customfields.php" and alter the code on line 293

from:

Code: [Select]

  $html .= VmHTML::row ('input', 'COM_VIRTUEMART_DEFAULT', 'custom_value', $datas->custom_value);


to:

Code: [Select]

  $html .= VmHTML::row ('textarea', 'COM_VIRTUEMART_DEFAULT', 'custom_value', $datas->custom_value);


Obvious this will only work until the VM does an update as your code will get over written..

I hope this helps.



Hi Ivus,

I wonder if you can shed some light on this, specifically:

Code: [Select]

`custom_value` char(255) COMMENT 'defaut value',


to

Code: [Select]

`custom_value` text COMMENT 'defaut value',


In PHPMyAdmin, I have found "custom_value" and changed the "char" to text, Comment is already set to "defaut value"
I made the additional changes to the customfields.php file too.

When I open up the backend, it now shows me a big textbox to add all the content to - I add the content, but as soon as I press save, it cuts it off at 255 characters again :(

Why would this be happening?


en jie rudd

  • Beginner
  • *
  • Posts: 38
hello CreativeDesigns

did you find a solution for this? I have exact the same problem.

regards

En Jie

Kintaro Oe

  • Beginner
  • *
  • Posts: 14
  • VirtueMart Version: 2.6
I think that this limit have to be removed... or at least let the user choose it (or set it to an hugher number like 2048).