I'm new to hooks, so pardon any ignorance in the questions...
So in my extension, (ext.staree.php), I have the following specifying the hook:
class Staree_ext
{
public $hooks = array('channel_entries_row');
...
Then in the activation method, I have this:
public function activate_extension()
{
foreach ($this->hooks as $hook)
{
$data = array(
'class' => __CLASS__,
'method' => 'get_current_entry_id',
'hook' => $hook,
'settings' => serialize($this->settings),
'priority' => 10,
'version' => $this->version,
'enabled' => 'y'
);
// insert in database
ee()->db->insert('extensions', $data);
}
}
The get_current_entry_id
is as follows: (Just to test right now)
public function get_current_entry_id($obj, $row)
{
echo "<pre>";
print_r($row);
echo "</pre>";
exit;
}
This gives me the following:
Array
(
[entry_id] => 30
[channel_id] => 5
[forum_topic_id] =>
[author_id] => 1
[ip_address] => ::1
...
I need to get the current entry_id
from my module mod.staree.php
.
So inside my Staree
class, I have the following method:
public function star()
{
$testID = // (THIS is where I need the current id from the ext)
$test = "Static return: 1, Passed Entry Id: ".ee()->TMPL->fetch_param('entry_id').", Dynamically Pulled Entry Id: ".$testID;
return $test;
}
I know if I pass the {entry_id}
like this: {exp:staree:star entry_id="{entry_id}"}
, it will work by fetching the params, but I would like to just get it from the template wherever it is.
I'm close, but not used to working with hooks. Any help would be GREAT!
Thanks.