Fruitcake_Gary Posted September 8 Share Posted September 8 Hi I have a small problem with the Image_slider module. I wanted to rework it a bit to display some recently purchased items in the store. However, there is a problem. adding a new value to 'getWidgetVariables' returns 1 public function getWidgetVariables($hookName = null, array $configuration = []) { $testData = [ ['name' => 'P 1', 'description' => 'desc 1', 'image' => 'url1.jpg', 'link' => 'link1'], ['name' => 'P 2', 'description' => 'desc 2', 'image' => 'url2.jpg', 'link' => 'link2'], ]; return [ 'lastPurchasedProducts' => $testData, 'test' => 'Test' ]; // $slides = $this->getSlides(true); // if (is_array($slides)) { // foreach ($slides as &$slide) { // $slide['sizes'] = @getimagesize((__DIR__ . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $slide['image'])); // if (isset($slide['sizes'][3]) && $slide['sizes'][3]) { // $slide['size'] = $slide['sizes'][3]; // } // } // } // // $config = $this->getConfigFieldsValues(); // return [ // 'homeslider' => [ // 'speed' => $config['HOMESLIDER_SPEED'], // 'pause' => $config['HOMESLIDER_PAUSE_ON_HOVER'] ? 'hover' : '', // 'wrap' => $config['HOMESLIDER_WRAP'] ? 'true' : 'false', // 'slides' => $slides, // ], // ]; } ps_imageslider.php <h1>test</h1> <div class="last-purchased-products"> <h1>{$test}</h1> <pre>{$lastPurchasedProducts|@print_r}</pre> <ul> {foreach from=$lastPurchasedProducts item=product} <li> {$product.name} {* <a href="{$product.product_link}">*} {* <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.product_title}">*} {* <strong>{$product.product_title}</strong>*} {* </a>*} {* <p>{$product.product_description|truncate:100}</p>*} {* Ilość: {$product.product_quantity} <br>*} {* Zakupiono: {$product.date_add|date_format:"%Y-%m-%d %H:%M"}*} </li> {/foreach} </ul> </div> ps_imageslider.php public function renderWidget($hookName = null, array $configuration = []) { if (!$this->isCached($this->templateFile, $this->getCacheId())) { $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); } return $this->fetch($this->templateFile, $this->getCacheId()); } I tried to combine this also in array_merge(...) and in it add these new variables, but still nothing Have any of you encountered this problem? Link to comment Share on other sites More sharing options...
ps8modules Posted September 10 Share Posted September 10 (edited) Hi. public function getWidgetVariables($hookName = null, array $configuration = []) { $slides = $this->getSlides(true); if (is_array($slides)) { foreach ($slides as &$slide) { $slide['sizes'] = @getimagesize((__DIR__ . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $slide['image'])); if (isset($slide['sizes'][3]) && $slide['sizes'][3]) { $slide['size'] = $slide['sizes'][3]; } } } $config = $this->getConfigFieldsValues(); $testData = [ ['title' => 'P 1', 'description' => 'desc 1', 'image_url' => 'url1.jpg', 'url' => 'link1', 'legend' => ''], ['title' => 'P 2', 'description' => 'desc 2', 'image_url' => 'url2.jpg', 'url' => 'link2', 'legend' => ''], ]; return [ 'homeslider' => [ 'speed' => $config['HOMESLIDER_SPEED'], 'pause' => $config['HOMESLIDER_PAUSE_ON_HOVER'] ? 'hover' : '', 'wrap' => $config['HOMESLIDER_WRAP'] ? 'true' : 'false', 'slides' => $testData /*$slides*/, ], ]; } OR public function getWidgetVariables($hookName = null, array $configuration = []) { $slides = $this->getSlides(true); if (is_array($slides)) { foreach ($slides as &$slide) { $slide['sizes'] = @getimagesize((__DIR__ . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR . $slide['image'])); if (isset($slide['sizes'][3]) && $slide['sizes'][3]) { $slide['size'] = $slide['sizes'][3]; } } } $config = $this->getConfigFieldsValues(); $slides[] = [ 'id_slide' => '1', 'position' => '1', 'active' => '1', 'title' => 'P 1', 'url' => 'link1', 'legend' => 'p-1', 'description' => 'desc 1', 'image' => 'url1.jpg', 'image_url' => 'url1.jpg', 'sizes' => @getimagesize('url1.jpg') , 'size' => 'width="1110" height="340"', ]; $slides[] = [ 'id_slide' => '2', 'position' => '2', 'active' => '1', 'title' => 'P 2', 'url' => 'link2', 'legend' => 'p-2', 'description' => 'desc 2', 'image' => 'url2.jpg', 'image_url' => 'url2.jpg', 'sizes' => @getimagesize('url2.jpg'), 'size' => 'width="1110" height="340"' ]; return [ 'homeslider' => [ 'speed' => $config['HOMESLIDER_SPEED'], 'pause' => $config['HOMESLIDER_PAUSE_ON_HOVER'] ? 'hover' : '', 'wrap' => $config['HOMESLIDER_WRAP'] ? 'true' : 'false', 'slides' => $slides, ], ]; } and not change slider.tpl !!! Edited September 10 by ps8modules.com (see edit history) Link to comment Share on other sites More sharing options...
Fruitcake_Gary Posted September 11 Author Share Posted September 11 Hi. Unfortunately it doesn't change anything. The point is that instead of the standard slider, I would like to convert this to show recently purchased products in the store But after dropping the results into the template public function renderWidget($hookName = null, array $configuration = []) { // if (!$this->isCached($this->templateFile, $this->getCacheId())) { // $this->smarty->assign($this->getWidgetVariables($hookName, $configuration)); $products = $this->getLastPurchasedProducts(); $this->smarty->assign(['p' => $products]); // } return $this->fetch($this->templateFile, $this->getCacheId()); } and print it into slider.tpl: <pre>{print_r($p)}</pre> I see only 1 😕 Link to comment Share on other sites More sharing options...
ps8modules Posted September 11 Share Posted September 11 I meant to indicate that you have to change the tpl in the module folder as well as in the themes and modules folder Link to comment Share on other sites More sharing options...
Fruitcake_Gary Posted September 14 Author Share Posted September 14 I have changed, passing props, however, it does not do anything, and even when I change the TPL to display the contents of the passed values there is nothing 😕 except '1' Link to comment Share on other sites More sharing options...
ps8modules Posted September 14 Share Posted September 14 (edited) Zip your module and upload it here. We can't see what you changed where! You are standing against a wall and you want to pass 😄 I gave you a code that works. If you don't want to load the images stored in the module, just comment out a few lines and no TPL needs to be changed! Edited September 14 by ps8modules.com (see edit history) Link to comment Share on other sites More sharing options...
Fruitcake_Gary Posted September 14 Author Share Posted September 14 I want to rework this module so that when I enable the option in the Module Configuration “LATEST_PURCHASES” it shows the five most recently purchased items. To the module itself, I added in the `public function renderForm()` this switch responsible for this, however, it too does not appear in the admin panel There is also a function `public function getLastPurchasedProducts($limit = 5, $id_lang = null)` that is responsible for this. ps_imageslider.zip Link to comment Share on other sites More sharing options...
ps8modules Posted September 14 Share Posted September 14 Okay. I'm not at the computer anymore today. I will check tomorrow and write the findings. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now