Jump to content

How do you translate content of module admin controller?


Jurist
 Share

Recommended Posts

I've created a module that adds a link to marketplace on product page (for example to amazon or eBay).

It adds a tab to back office, after accessing that tab you see it's AdminController who handles the form and saving the link (url, name, type, related product) to database. It all works well.

However now I need to create a different link for different language.

I've created appropriate _lang database, however despite this, when I try to save new object, it says Property Mwrmarketplacebuttons->mwr_content is empty. That's the field that needs to be translated.

So far I've added:

    public function __construct() 
    {
        $this->bootstrap = true;
        $this->table = 'mwrmarketplacebuttons';
        $this->className = 'Mwrmarketplacebuttons';
        $this->lang = TRUE;
        $this->bootstrap = TRUE;
        $this->addRowAction('edit');
        $this->addRowAction('delete');
        $this->context = Context::getContext();

 

and my input looks like that:

                'input' => array(
                    array(
                        'type' => 'text',
                        'label' => $this->l('Button URL'),
                        'name' => 'mwr_content',
						'id' => 'mwr_content',
						'lang' => true,
                        'size' => 33,
                        'desc' => $this->l('Full listing address. Example: https://amazon.com/your-listing-url'),
                        'required' => true
                    ),

my sql for lang table:

        Db::getInstance()->Execute('
            CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'mwrmarketplacebuttons` (
                `id_mwrmarketplacebuttons` int(11) NOT NULL AUTO_INCREMENT,
                `mwr_button_type` int(11) DEFAULT NULL,
                `mwr_content` varchar(5000) DEFAULT NULL,
                `mwr_product` int(11) DEFAULT NULL,
                `mwr_product_name` varchar(5000) DEFAULT NULL,
                `mwr_status` int(11) DEFAULT 0,
                `active` int(11) DEFAULT 0,
                PRIMARY KEY (`id_mwrmarketplacebuttons`)
        ) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8');
        Db::getInstance()->Execute('
            CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'mwrmarketplacebuttons_lang` (
                `id_mwrmarketplacebuttons` int(10) unsigned NOT NULL,
                `id_lang` int(10) unsigned NOT NULL,
				`mwr_content` TEXT DEFAULT NULL,
                PRIMARY KEY (`id_mwrmarketplacebuttons`,`id_lang`),
            KEY `id_mwrmarketplacebuttons` (`id_mwrmarketplacebuttons`)
        ) ENGINE='._MYSQL_ENGINE_.' default CHARSET=utf8');

anything else I need to change to make it work?

When I add new button it looks good, but it doesn't save it. Picture attached.

Help appreciated.

image.thumb.png.2520d42715b0bce0ffef284bfc01bb41.png

Share this post


Link to post
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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More