Sunday, 15 September 2013

php - Getting NULL in template - OpenCart 2.0 -


I have to render home.tpl product_list.tpl > But it is giving me the NULL

controller file

  /controller/product/product_list.php  

Code:

  class controller productive product list controller {public function index () {$ this- & gt; Load-> Model ('catalog / category'); $ This- & gt; Load-> Model ('list / product'); $ This- & gt; Load-> Model ('device / image'); $ Filter_data = array ('filter_tag' = & gt; 'featured', 'border' => 9); $ Data ['result'] = $ this- & gt; Model_list_product- & gt; GetProducts ($ filter_data); If (file_exists get (DIR_TEMPLATE. $ This-> config- & gt; ('config_template'). '/template/common/productlist.tpl')) {$ this-> Feedback-> SetOptput ($ - >--> see-> (- 'config_template'). '/template/common/productlist.tpl', $ data); } And {$ this- & gt; Feedback-> SetOptput ($- >--> Load-> View ('Default / Template / Normal / Product List.' ', $ Data)); }}}  

template to render

  /template/product/productlist.tpl  

Code:

  & lt ;? Php var_dump ($ result); ? & Gt; & Lt; H2 & gt; Products are here & lt; / H2 & gt;  

then home.php controller

$ data ['special_mod'] = $ this- & gt; Load-> Controller ('product / product_list');

and $ special_mod in the normal / home.tpl file

The problem was in /controller/product/product_list.php

method $ this-> The response-> SetOptput does not return the value only, but sends the user to a different page, while what I wanted, only the Productlist.tpl string is so much that I want to code Have to change

  if (get file_exists (DIR_TEMPLATE. $ This-> config- & gt; ('config_template'). '/template/common/productlist.tpl')) { $ This- & gt; Get feedback-> setOptput ($-> this-> load-> ($-> get-> config- & gt; ('config_template'). '/template/common/productlist.tpl', $ data )); } And {$ this- & gt; Feedback-> SetOptput ($- >--> Load-> View ('Default / Template / Normal / Product List.' ', $ Data)); }  

with

  if (file_exists (get DIR_TEMPLATE. $ This-> config- & gt; ('config_template'). ' / Template / general /productlist.tpl ')) {return $ this-> Load-> View ($ -> get-> this-> config- & gt; ('config_template'). '/template/common/productlist.tpl', $ data); } And {return $ this-> Load-> View ('Default / Template / General / Product List.' ', $ Data); }  

No comments:

Post a Comment