Adding icons or other html to a simple module's list_items()

edited January 2014 in Share
I think it was possible to add html to columns in the list_items() display back in v.093, but I can't find the example I'm thinking of.

For instance, if there is a url column which is a path to an icon or thumbnail, is it possible to show that as an img tag in the simple module list page?

Comments

  • edited 2:35AM
    In your list_items method, you simply just need to loop through the data and add the HTML code before returning it (the fuel_assets_model does this).
  • edited January 2014
    Of course!

    Just for the record:
    function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'asc', $just_count = FALSE) { $this->db->select('id, name, link, active, icon_img'); $data = parent::list_items($limit, $offset, $col, $order, $just_count = FALSE); foreach($data as $key => $value) { $data[$key]['icon'] = '<img width="32" src="'.img_path($data[$key]['icon_img']).'">'; } return $data; }

    This example creates an img tag using the file path in the column icon_img. $data[$key]['icon'] is a new column for the tag.
Sign In or Register to comment.