Adding fields to list_items data for 'pages'

edited July 2011 in Feature Requests
Hello,
for learning purposes, i would like to hook into the returned data of 'pages' list view, and add some more fields of my own preference. I have a couple of problems:

1) I've added the list_items function to the pages_model.php file inside the fuel module, but no matter what i add to the select array, it won't be rendered in the resulting table :

function list_items($limit = NULL, $offset = NULL, $col = 'location', $order = 'asc')
{
$this->db->select('id, location, layout, published, test as Sometext', FALSE);
$data = parent::list_items($limit, $offset, $col, $order);
return $data;
}
where 'test' is an actual table field in the DB.

I don't get it, the same method works for my own modules...

2) What if I wanted to 'merge' some table rows with the page_model table data? ie. say i wanted to display the picture of the author in the list view of the 'pages' model? Do I have to ditch the parent::list_items call and just do my own from scratch, making sure the data gets returned in an array?

Hope it's clear... thanks!

Comments

  • edited 3:19PM
    1. You will need to alter the table_headers parameter in fuel/modules/fuel/config/fuel_modules.php on line 17 or simply remove it. If that parameter is not set, then it will just use the data from your select.

    2. You can do some further processing of the field data to get the field values you want, including html for images you want to display in the table right after your $data = parent::list_items($limit, $offset, $col, $order); call. The data table just takes an array of associative arrays to render.

    Hope that helps.
  • edited 3:19PM
    Wow thanks!!! Exactly what i needed!
  • edited 3:19PM
    One more thing though,
    can i assign those table_headers directly from the pages_model?
  • edited 3:19PM
    No. The way to do it in the model is to actually remove the parameter from the fuel_modules.php file so the default will kick in which will be only those values in your select statement.
  • edited 3:19PM
    ah ok so whatever the data array indexes are, those will be the table headers. gotit!
Sign In or Register to comment.