Extending the pages model
Hello,
I'm trying to extend the 'Pages' section of the admin to include an array of uploadable images for a page.
I could be way of the mark here but reading this page (
http://www.getfuelcms.com/user_guide/modules/hooks) suggests I should be able to hook into before the page variables gets saved, allowing me to grab the file uploads and process/save.
I can't figure out how to get a hook loaded and called. The user guide says I should add the hook into fuel/modules/application/config/hooks.php, however fuel/modules/application does not exist. I've tried adding the hook into several other hooks.php with no luck. First time in a long time I've felt lost with a PHP app
Any pointers to how I should go about doing this?
Thanks!
Comments
fuel/application/config/hooks.php
There should be an example in that file that that may help. Similarly, you can overwrite the model being used for the pages module by adding the following to the fuel/application/config/MY_fuel_modules.php file:
$config['module_overwrites']['pages']['model_name'] ='MY_pages_model';
Where MY_pages_model.php model exists in your fuel/application/models/MY_pages_model.php and extends the fuel/modules/models/pages_model.php (or fuel_pages_model.php in the 1.0 beta)
This is the path the documentation states.. which does not exist. Are you referring to fuel/modules/application/config/hooks.php? That does have an example as you mentioned although I couldn't get that to load any hooks.
Your idea of overloading the pages module makes more sense though. I have it overloading OK but any of the on_* mathods only seem to pass the 'Page Information' section values. Is there a different way to get the page variables before they are saved?
It is the form_fields() method I cannot find that builds the page variables section too. Pages_model::form_fields() appears to only deal with the page information.
Apologies for getting this confused!
You may be wanting the pagevariables_model.php instead.