Modules - Table_headers

rl2rl2
edited April 2018 in Modules

Hello,

On the front-end of the website there is a series of questions from users which is stored in a 'question_and_answers' table (let's call it QA for short) on the page there is a 'Did you find this useful?' with Yes and No buttons. Clicking Yes or No updates an existing row or adds a new row to a second Ratings table.

The Ratings table has a unique key (qa_ref) identifying which question the user has 'thumbed up' or 'thumbed down'.

PK UNIQ
id qa_ref date thumbs_up thumbs_down
1 3 blah blah 1 3
2 11 blah blah 3 0

Everything is functioning correctly between the two tables during user interaction. Now I'd like to present the thumbs_up and thumbs_down information to the cms user in the back-end.

I've looked at MY_fuel_modules.php and I can see here we can add additional columns to the 'table-headers' indice, but that only brings in columns which reside in the same model.

So the two choices are...

a) Work out how to present the two additional columns from the Ratings table alongside the QA table headers.
b) Or simply 'present' the Ratings table as a separate model so at the very least the cms user can see the data without having to jump into an SQL client.

Option A would certainly be preferred if it indeed possible.

Comments

  • By default, the list_items method will return all the columns of your model. The table_headers module parameter is a way to further limit that list down. However, you can add additional selects and joins to the data table query in the model's list_items method to return the data set you'd like (the data table simply expect an array of row data). Some of the built in model's do this (Fuel_blocks_model, Fuel_categories_model, Fuel_tags_model...etc).

Sign In or Register to comment.