Jump to content

Helperlist and custom images path


Recommended Posts

Hello, i'm trying to show images in my helperlist from a custom path, can this be achievable?

 

So instead of 'image' => 's' , I would like it to be 'image' => 'localhost/prestashop/themes/default/images/'//My custom path

and instead of 'image_id' => 1, I would like it to be 'image_id' => 'test.jpg'//name of the image,

 

I searched the forum for a post similar with this one, but I couldn't find one, any suggestions, ideas?I'm getting my data for my list from the database, but i didn't put it in here.

 

My helperlist looks something like this:

 



private function initList()
{
$this->fields_list = array(
'id_category' => array(
'title' => $this->l('Id'),
'width' => 140,
'type' => 'text',
),
'name' => array(
'title' => $this->l('Name'),
'width' => 140,
'type' => 'image',
'image' => 'localhost/prestashop/themes/default/images/',
'image_id' => 'test.jpg',
),
);
$helper = new HelperList();

$helper->shopLinkType = '';

$helper->simple_header = true;

// Actions to be displayed in the "Actions" column
$helper->actions = array('edit', 'delete', 'view');

$helper->identifier = 'id_category';
$helper->show_toolbar = true;
$helper->title = 'HelperList';
$helper->table = $this->name.'_categories';

$helper->token = Tools::getAdminTokenLite('AdminModules');
$helper->currentIndex = AdminController::$currentIndex.'&configure='.$this->name;
return $helper;
}


 

Thank you very much!

Link to comment
Share on other sites

  • 1 year later...

Hello!

 

Maybe i am late. But maybe some one has the same problem. Sorry!!

 

In my custom module I use a custom folder and tpl:

 

This is my function:

 public function displayList()
 {

   $receptes = $this->getReceptes(); // I USE THIS FUNCTION TO GET MY INFORMATION
   foreach ($receptes as $key => $recepta)
   {
     $recepta[$key]['status'] = $this->displayStatus($recepta['id_recepta'], $recepta['active']); // I USE THIS FUNCTION TO PRINT HTML CODE ABOUT ACTIVE OR NOT ACTIVE
   }

   $this->context->smarty->assign(
     array(
       'link' => $this->context->link,
       'receptes' => $receptes,
       'image_baseurl' => $this->_path.'images/'
     )
   );

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

"images/" is the a folder, placed in module's folder. Then you can format the list with the tpl "list.tpl". 

 

Next time, try get some module with images. Then you can read the code and get an idea for your custom module. 

Link to comment
Share on other sites

  • 4 weeks later...
Hi,

 

Define your field list array like this for image column

 

$this->fields_list['image'] = array(

            'title' => $this->l('Photo'),

            'align' => 'center',

            'image' => 'p',

            'orderby' => false,

            'filter' => false,

            'search' => false

        );

 

And pass the image id in the field value array.

 

$this->fields_value[0]['image'] = $id_image(Pass the ID of the image which you want to display in this column);

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...