Results 1 to 3 of 3

Thread: Create a folder when writing a new catalog item to the db

  1. #1
    New user
    Join Date
    02-25-10.
    Posts
    24

    Default Create a folder when writing a new catalog item to the db

    Hi
    I would like to automate a process: generate a folder dinamically when creating a new catalog item to store entry relevant files (pictures and attachment), the folder would be named based on the timestamp of the item (xxx-Y.m.d) .
    I would like to save the item and then have ready the folder to upload the files in it, or copy files located in a temp folder to the relevant folder.

    I need it with catalog 2.0 and contao 2.11
    I am not sure how to approach this, is there any hook that I could use for, to trigger a custom action when creating o saving the item to the database.

    any help is welcome, thanks

  2. #2
    Experienced user
    Join Date
    01-12-10.
    Posts
    814

    Default Re: Create a folder when writing a new catalog item to the d

    Assuming this is happening in the backend; you can extend the DCA. If you add a save_callback to one of the fields you can run your own custom code. The entry you need to add to an existing field looks like this (and you can find examples in most extensions)

    Code:
    			'save_callback'			  => array
    			(
    				array('tl_catalog_items_createdir', 'createUserDir'),
    			)
    tl_catalog_items_createdir is a classname I made up which you have to create in a custom dca file (for example /system/modules/catalog_createdir/dca/ tl_catalog_items.php). This file is the file which you must use to edit the dca.

  3. #3
    New user
    Join Date
    02-25-10.
    Posts
    24

    Default Re: Create a folder when writing a new catalog item to the d

    Clear to me now, many thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •