Jump to content

Module can't assign the values to template file?


prestashop_newuser
 Share

Recommended Posts

Hi,

I am just newbie to prestashop. I am doing a module. In that the module install part is

 

public function install()
 {
   if(!parent::install())
     return false;
   if (!$this->registerHook('leftColumn'))
     return false;
   if (!$this->registerHook('header'))
     return false;
   if (!$this->registerHook('rightColumn'))
     return false;
}

 

In that module I have done add, edit and delete for store contact info. Now I have a function named as public function hookHome($params) where I have assigned smart file(.tpl) with the module name and I want to show that tpl file should come in home page. for that I have my function is like this

 

 public function hookHome($params)
 {
   $defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));
   global $cookie, $smarty;
   $sql_select="SELECT DISTINCT country_name,country_ISO from "._DB_PREFIX_."storeinfo where status='1'";
      $value=Db::getInstance()->ExecuteS($sql_select);
      print_r($result);

     while($row=mysql_fetch_assoc($result))
     {
     $value[] = $row;
 }
      $smarty->assign('array',$value);
      $smarty->assign('default',$defaultLanguage);
    return $this->display(__FILE__, 'storeinfo.tpl');
 }

 

But here I can't able to send the values to .tpl file. Can someone kindly tell me what's the issue here?

Share this post


Link to post
Share on other sites

so you wanted to say that variables:

{$array}

{$default}

don't work in your theme file?

 

 

can you put there {debug} and then you will see popup with all available variables in the .tpl file

your new variables appear on the list?

Share this post


Link to post
Share on other sites

yes..can you tell me how to debug the values in template file?

 

so you wanted to say that variables:

{$array}

{$default}

don't work in your theme file?

 

 

can you put there {debug} and then you will see popup with all available variables in the .tpl file

your new variables appear on the list?

 

Hi,

I am just newbie to prestashop. I am doing a module. In that the module install part is

public function install()

{

if(!parent::install())

return false;

if (!$this->registerHook('leftColumn'))

return false;

if (!$this->registerHook('header'))

return false;

if (!$this->registerHook('rightColumn'))

return false;

}

 

In that module I have done add, edit and delete for store contact info. Now I have a function named as public function hookHome($params) where I have assigned smart file(.tpl) with the module name and I want to show that tpl file should come in home page. for that I have my function is like this

public function hookHome($params)

{

$defaultLanguage = (int)(Configuration::get('PS_LANG_DEFAULT'));

global $cookie, $smarty;

$sql_select="SELECT DISTINCT country_name,country_ISO from "._DB_PREFIX_."storeinfo where status='1'";

$value=Db::getInstance()->ExecuteS($sql_select);

print_r($result);

 

while($row=mysql_fetch_assoc($result))

{

$value[] = $row;

}

$smarty->assign('array',$value);

$smarty->assign('default',$defaultLanguage);

return $this->display(__FILE__, 'storeinfo.tpl');

}

 

But here I can't able to send the values to .tpl file. Can someone kindly tell me what's the issue here?

Share this post


Link to post
Share on other sites

okay, but in this case |print_r only show the contents of the variable. If there is no contents - then it will show nothing.

What i wanted is to check if this variable is defined. In this case, you need to use {debug} - you will see all smarty template variables, even if they are empty.

 

hope that you understand my point of view ;)

Share this post


Link to post
Share on other sites

okay, but in this case |print_r only show the contents of the variable. If there is no contents - then it will show nothing.

What i wanted is to check if this variable is defined. In this case, you need to use {debug} - you will see all smarty template variables, even if they are empty.

 

hope that you understand my point of view ;)

 

Yes I understand that and I used {debug} in my .tpl file but it did not showed anything...I think my tpl file is not properly assigned with home page?

Share this post


Link to post
Share on other sites

it's because in your install function:

if(!parent::install())
return false;
if (!$this->registerHook('leftColumn'))
return false;
if (!$this->registerHook('header'))
return false;
if (!$this->registerHook('rightColumn'))
return false;
}

 

you don't have registerhook('home')

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