Jump to content

about hookDisplayAdminProductsExtra for 1.7


langziyang

Recommended Posts

in ps1.7,how to code hookDisplayAdminProductsExtra?

this is mine:

public function hookDisplayAdminProductsExtra($params)
    {
        if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) {
            $id_product = (int)Tools::getValue('id_product');
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'etmustpaid` a 
                                                                                LEFT JOIN `' . _DB_PREFIX_ . 'etmustpaid_content` ec ON(a.`id_etmustpaid`=ec.`id_etmustpaid`) 
                                                                                WHERE a.`id_product`=' . (int)$id_product);
            $contents = array();
            foreach ($result as $key => $content) {
                $contents[$content['id_lang']] = $content['content'];
            }
            $this->context->smarty->assign(array(
                'etmust_paid_product_content' => $contents,
                'languages'                   => Language::getLanguages(true),
                'default_language'            => (int)Configuration::get('PS_LANG_DEFAULT'),
            ));
            return $this->display(__FILE__, 'views/templates/hook/displayAdminProductsExtra.tpl');
        }
    }

and this is result:

 

post-620354-0-80367600-1504346651_thumb.png

post-620354-0-48041800-1504346656_thumb.png

 

Link to comment
Share on other sites

so create such code in your .tpl file or use form helper to build such form:

http://doc.prestashop.com/display/PS16/Using+the+Helper+classes (it's for prestashop 1.6 but it is applicable also in 1.7)

 

you mean code on public function hookDisplayProductExtraContent($params){}?

 

can not do anything on this hook;

this is my code:

public function hookDisplayProductExtraContent($params)
    {
        var_dump('Can do?');
        $this->context->smarty->assign(array('id_product' => $params['id_product']));
        $helper = new HelperForm();
        return $helper->generateForm(array(
            'form' => array(
                'legend' => array(
                    'title' => $this->getTranslator()->trans('Sssss'),
                ),
                'input'  => array(
                    array(
                        'type'  => 'textarea',
                        'label' => $this->getTranslator()->trans('test'),
                        'name'  => 'etmust_paid_product_content',
                    ),
                ),
            ),
        ));

        //return $this->context->smarty->fetch('module:etmustpaid/views/templates/hook/displayProductTabContent.tpl');
        /*
        if (Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) {
            $id_product = (int)Tools::getValue('id_product');
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'etmustpaid` a
                                                                                LEFT JOIN `' . _DB_PREFIX_ . 'etmustpaid_content` ec ON(a.`id_etmustpaid`=ec.`id_etmustpaid`)
                                                                                WHERE a.`id_product`=' . (int)$id_product);
            $contents = array();
            foreach ($result as $key => $content) {
                $contents[$content['id_lang']] = $content['content'];
            }
            $this->context->smarty->assign(array(
                'etmust_paid_product_content' => $contents,
                'languages'                   => Language::getLanguages(true),
                'default_language'            => (int)Configuration::get('PS_LANG_DEFAULT'),
            ));
            return $this->display(__FILE__, 'views/templates/hook/displayAdminProductsExtra.tpl');
        }
        */
    }

i use more way,buy the page give me always like this:

post-620354-0-23616800-1504957740_thumb.png

post-620354-0-34276200-1504957744_thumb.png

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