Jump to content

Adding the new hook to prestashop and attaching it to admin page


NatasaN

Recommended Posts

Hi,

I'm trying to create a module for admin panel -> Store Contacts.

The idea is to add just one input csv file field.

 

I created a hook ActionAdminStoresControllersCsvUpload , and connected it with Store Contacts page by overriding this controller: AdminStoresController adding only this function:

 

 public function initContent() {
            parent::initContent();
            Hook::exec('actionAdminStoresControllersCsvUpload');
        }

 

The next step is creating a module: uploadStoresViaCsv. The Problem Starts Here. For the beginning I want to display only text at Store Contacts page.

 

In the module php file i added this function:

 

 public function hookActionAdminStoresControllersCsvUpload() {
          
            $helpme="Test if we are connected";
            
           $this->smarty->assign('helpme', $helpme);
         
 
return $this->display(__FILE__, 'upload_stores.tpl');
            
        }
 
and create in root tpl file with this code
 
<div class="col-lg-4">
            
            {$helpme}
</div>
 
and NOTHING is happening. :( I don't know why. Wen i do var_dump of $helpme in php I see the content. But when I send the value regularly, i get nothing.
 
I think that the problem is in new hook. 
 
What do you think?

 

Link to comment
Share on other sites

I change that. I created the hook hookDisplayCsvUpload. 

If I add this in function hookDisplayCsvUpload

 

             public function hookDisplayCsvUpload($params) {
         
                   $this->smarty->assign('helper', "test me");
                   var_dump($this->display(__FILE__, 'views/upload_csv_form_admin.tpl'));
                   exit();
                  return $this->display(__FILE__, 'views/upload_csv_form_admin.tpl');
            
              }
 
The result will be the form from tpl. file :
string '<div class="form-group">
    <label class="control-label col-lg-3">
        <span class="label-tooltip" data-toggle="tooltip" data-html="true" title="" data-original-title="You can upload a maximum of 3 images.">
            Thumbnails
        </span>
    </label>
    <div class="col-lg-4">
        test me
    </div>
</div>
' (length=287)
 
BUT the MAIN problem is that I dont see that content om my admin page Store Contacts.
Any idea?
Edited by NatasaN (see edit history)
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...