How to show images from a cdn url in admin listing page using admin controller in prestashop 1.7

58 Views Asked by At
<?php

class AdminColorNameTagPositionController extends ModuleAdminController
{
    public function __construct()
    {
        $this->table = 'color_name_tags_design_position';
        $this->_orderBy = 'id';
        $this->className = 'AdminColorNameTagPosition';
        $this->list_no_link = true;
        $this->bootstrap = true;
        $this->actions = [];  
        $this->tpl_title = 'Priority for Designs and default Colors colored name label';
        $this->context = Context::getContext();
        
        
        
        $this->fields_list = array(
            'image' => array(
                'title' => 'Image',
                'image' => 'image',
                'orderby' => false,
                'search' => false,
                'callback' =>'renderImage'
            ),
            'design_id' => array(
                'title'     => 'Design ID',
                'width' => 25
            ),
            'position' => array(
                'title'     => 'Design Position',
                'width' => 25
            )
        );   
        $this->_select .= '1 as image';    
        parent::__construct(); 
        
    }

    public function renderList()
    {
        return parent::renderList();
    }

    public function renderImage($row)
    {
        // Return the HTML code to display in the custom column
        return '
<img src="cdn url/'. $row['design_id'] .'?color=1" alt="Image" class="img-thumbnail" />';
    }

}

Using prestashop 1.7. I have a table named color_name_tags_design_position.
In this table, I have 2 columns named design_id and position.
In the listing page, I want to show the image from a cdn corresponding to the design_id.

The renderImage() in the above code does not show any message on the listing page.

How to fix this issue?

0

There are 0 best solutions below