Jump to content

Adding new field to product_lang


drow

Recommended Posts

Hello,

when adding a field to the administration panel for categories, I currently get the error "Hack attempt [field] is empty for default language.". But in the $_POST vars the field exists. What I did is the following:

1. Added new column 'nav_title' to ps_product_lang table in database.

2. Modified classes/Category.php:
2.a. added new property 'nav_title'
2.b. added 'nav_title' to property $fieldsRequiredLang
2.c. added 'nav_title' => 64 to property $fieldsSizeLang
2.d. added 'nav_title' => 'isGenericName' to property $fieldsValidateLang
2.e. added 'nav_title' to argument array of parent::getTranslationsFields in method getTranslationsFieldsChild

3. Modified tabs/AdminCategories.php: added lines on method displayForm as follows:

              '.$this->l('Navigation title:').' 
';
       foreach ($languages as $language)
           echo '

                       <input type="text" style="width: 260px" name="nav_title_'.$language['id_lang'].'" id="nav_title_'.$language['id_lang'].'" value="'.htmlentities($this->getFieldValue($obj, 'nav_title', intval($language['id_lang'])), ENT_COMPAT, 'UTF-8').'" /> *
'.$this->l('Invalid characters:').' <>;=#{} 
';
       $this->displayFlags($languages, $defaultLanguage, $langtags, 'cnav_title');
       echo '        



Is there anything I forgot?

Cheers


--

As I found a solution for it and didn't want this post to reside without, in case someone stumbles over it..

The problem wasn't about something missed in the procedure, but as all sub-categories get updated on an update as well, the respective field for those was empty and therefore the error got fired.

Soulition: The field is now dynamically added or removed (just shows up for categories having home category set as parent).

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