I am working on an addon for EE3 and would like to be able to pull whatever the current {entry_id} is to use inside the mod file without requiring the user to have to add it as a param.
Is this something that can be done? I feel like I have gone in circles through the docs as well as printing objects, etc...
I know I could do something like this:
{exp:my_module:my_method entry_id="{entry_id}"}
I would just like them to be able to use:
{exp:my_module:my_method}
and whatever optional params are wanted if need be.
Thanks
* EDIT *
@derek-jones pointed me in the right direction by sending me to the channel_entries_row in the Channel Module Extension Hooks here.
However, after reading through it, AND being new to hooks and how to use them, I am still unsure as to how to retrieve the data I am after. Any help in this would be greatly appreciated.
I created an extension for my module and in my hooks, I included it in the extension like this:
public $hooks = array('channel_entries_row');
(I placed it into an array so I can loop through all I end up using and adding them in one statement. I know it looks off here.)
So according to the docs...
How it’s called:
$row = $this->extensions->call('channel_entries_row', $this, $row);
if ($this->extensions->end_script === TRUE) return $tagdata;
So do I need to create a method inside my extension named the same as the hook? or create my own method and just call the hook?
So something like this?
public function channel_entries_row($this, $row)
{
// Check if we're not the only one using this hook
if (ee()->extensions->last_call !== FALSE) {
$config = ee()->extensions->last_call;
}
// build the rows so we can get the entry_id
$row = $this->extensions->call('channel_entries_row', $this, $row);
echo "<pre>";
print_r($row);
echo "</pre>";
exit;
// The above are just there for trying to test right now...
if ($this->extensions->end_script === TRUE) return $tagdata;
}
...and then call it from my module when needed?
Just trying to understand a bit here. I don't know if I need more coffee or what. ;)