modifying asset uploading

edited September 2014 in Modules
When creating page dyanmically, i have few asset fields. However these assets are untracked. I am planning to build a table to track assets related to each pages, so when i am backing up pages, i am able to back up the associated assets too, which class can i modify to handle this kind of request.

Comments

  • edited 11:19AM
    I would probably recommend extending the fuel_pages_model and overwriting the module's model as displayed here:
    http://docs.getfuelcms.com/modules/simple#overwrites

    Then you can leverage a model hook like on_before_save to do any further processing. If you do, use a hook and have extended the model, be sure to call parent::on_before_save() in your on_before_save method as well.
  • edited 11:19AM
    hmmm, so you mean:

    1) i upload the asset by clicking upload button beside asset fields
    2) the asset fields is populated

    i then use on_before_save to save the asset fields to an asset table?

    However, there is also an upload button when click the image icon on markitup textfield. how to handle this part?
  • edited 11:19AM
    In this case, it sounds like you may want to overwrite the assets module with your own asset model that extends fuel_assets_model. There is an on_after_post hook you can use to do the saving to the asset table. The current fuel_assets_model on_after_post hook doesn't do anything so you would need to override that model and add functionality to that hook method.

    Additionally, there are "module hooks" which operate outside of the model and act like normal CI hooks. I just added this in the develop branch to the assets module (that module didn't have them implemented for the creation process since it dealt with the file system and not the database).
    http://docs.getfuelcms.com/modules/hooks

    $hook['before_create_assets'] = array( 'class' => 'Test_hooks', 'function' => 'before_create_assets', 'filename' => 'Test_hooks.php', 'filepath' => 'hooks', 'params' => array(), 'module' => 'app');
Sign In or Register to comment.