• Register
Plug-in Tutorial Build an EC-CUBE plug-in

Top Commentators

114

1

EC Mike

SHOGUNSHOGUN

32

2

hrbabu

SAMURAISAMURAI

29

3

Sumant Jha

SAMURAISAMURAI

29

4

justcubed

SAMURAISAMURAI

21

5

Ashok Kafle

SAMURAISAMURAI

21

6

shahith

SAMURAISAMURAI

14

7

Jeemusu

KABUKIKABUKI

14

8

Yangsin

KABUKIKABUKI

9

9

Zaw Hlaing Bwar

GEISYAGEISYA

8

10

Fei Liu

GEISYAGEISYA

Ranking Key

  • FUJISANFUJISAN1,000+ posts
  • SAKURASAKURA500+ posts
  • SHOGUNSHOGUN100+ posts
  • NINJYANINJYA50+ posts
  • SAMURAISAMURAI20+ posts
  • KABUKIKABUKI10+ posts
  • GEISYAGEISYALess than 10 posts

where's the code to assign $arrProducts to Smarty object?

0 votes
Hi, I'm new Ec-cube members please help me to approach it more clearly.

I check "LC_Page_Product_List.php" file and it collect all product information as $arrProducts

I check "list.tpl" file that have :  <!--{foreach from=$arrProducts item=arrProduct name=arrProducts}--> line.

as my question ... how to assign $arrProducts to Smarty object before call template file,

or where's the code to assign $arrProducts to Smarty object .

Thanks you very much!
asked 2013-10-06 by NewDays (270 points) GEISYAGEISYA

1 Answer

0 votes

Oh! maybe I found it,

SC_Display.php   

function prepare($page, $is_admin = false) {
        if (!$this->deviceSeted || !is_null($this->view)) {
            $device = ($is_admin) ? DEVICE_TYPE_ADMIN : $this->detectDevice();
            $this->setDevice($device);
        }
        $this->assignobj($page);

please comment if you have ~~ thanks

answered 2013-10-07 by NewDays (270 points) GEISYAGEISYA
If you want to create an object that can be accessed from your smarty files, all you have to do is edit your action() function in the corresponding LC_xxxx file for your tpl.

So, for example, let's say you wanted to add smarty variable $mySmartyVar to produts/detail.tpl:

Edit data/class/products/LC_Page_Products_Detail.php and in the action() function, add the following code: $this->mySmartyVar = "your value";

Then, when you call <!--{$mySmartVar}--> in detail.tpl it should display your value.

Also: you should generally be careful about editing the class files (SC_ prefix)  since these include functions that are called throughout your EC Cube installation. Just because it yields the correct result for the page you're working on doesn't mean it will function properly site-wide!
Nice answer! thanks
...