Reputation: 21282
I have a website built on the Ushahidi platform that uses the Kohana framework. Currently the site runs on Kohana 2.x.
I would like to grab the report title for each report page on my website. The website in question is a number of "report" pages.
I'm new to code in general and this is my first time coming across a MVC framework. It sounds good though, as far as I can interpret one can pull info out of the db without writing a sql query but rather by calling it within the view itself. Right?
The documentation gives some examples of using Kohana to grab info out of the DB here: https://wiki.ushahidi.com/display/WIKI/Database+access
Here's one of the examples I tried that outputs the expected data:
$reportcount = ORM::factory('incident')->count_all();
So, as someone new to this, I wanted to use that snippet of code as a base and edit it to get what I need for my current task. The website in question is a series of "reports" and for each report page I would like to add the report title to a meta description tag in the head.
Here is the code that outputs the report title further down the DOM on a report page:
<h1 class="report-title"><?php
echo html::escape($incident_title);
I cannot find the escape function anywhere to refer to and, since I'm adding this meta tag via a plugin, the function that generates the meta tag exists on a separate script. I tried simply cutting and pasting echo html::escape($incident_title);
but as expected the variable $incident_title was not recognized.
Each report page somehow seems to know it's id $incident_id. I know this after experimenting with the following:
$incititle = ORM::factory('incident')->table_column('incident_id');
echo $incititle;
This gave the error message "Invalid method table_column called in Incident_Model"
Then I tried:
$incititle = ORM::factory('incident')
->where('incident_title', 'incident')->find();
echo $incititle;
This just returned the number 10. I was expecting (more hoping) it would return "Hello Ushahidi", the default example report when one installs the Ushahidi platform.
Here is a screen shot of the incidents table:
I want the incident_title for each report - "Hello Ushahidi!" in the example report shown in the table.
It seems too that "incident" when used as a parameter in the code I tried above seems to recognize what specific incident is being referred to. So in theory each view should have it's own ID magically stored away somewhere, I do not know how but appears to be the case.
How would I grab the incident_title from the incident table for each incident/report?
Upvotes: 0
Views: 138