Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » pickup subdir from table and put into upload_subdir
Re: pickup subdir from table and put into upload_subdir [message #1559 is a reply to message #1363] Thu, 21 August 2008 17:18 Go to previous messageGo to previous message
ikatz is currently offline  ikatz
Messages: 40
Registered: December 2007
Location: Durham, NH
Member
I came across this thread from a Google search. I think I am working on something along the same lines, so here is my solution for whoever comes next.

I was setting up a file upload directory that would hold a large number of files: several per database record, and many records. In order to make the directory more manageable, I set up a subdirectory for each record (based on primary key) and accessed the file upload screen from a list1 transaction.

You have to put the file upload task as a navigation button in your list1 transaction, and mark it as "preselect" (I didn't try enq1). Then when you select an item from your list1 and click "File Upload", you will get your primary key as an element of the fieldarray argument to _cm_initialiseFileUpload. Then you can use it to set $this->upload_subdir.

The only downside to this is that there seems to be no way to browse the directory from Radicore. The most apt transaction would be a filepicker, because it will show you the contents of a directory ... but the problem is that there is no way (that I can see) to get the primary key of the record you are looking at from _cm_initialiseFilePicker() -- it takes no arguments.

So you have to do it the "hack" way:
    function _cm_initialiseFilePicker ()
    // perform any initialisation before displaying the File Picker screen.
    {

        $sv = $GLOBALS['HTTP_SESSION_VARS'];
        $svp = $sv['pages'];
        $keys = array_keys($svp);
        //get previous page in stack ... you may need to adjust the 2
        $page = $keys[count($keys) - 2];
        $task = $svp[$page]['task_id'];
        $where = $svp[$page][$task]['where'];

        //the field we want
        $field = 'your_table_pkey_id';

        //Tony's sample code (more or less)
        $dbobject =& singleton::getInstance('your_table');
        $dbobject->sql_select = $field;
        $data = $dbobject->getData($where);

        $primary_key = $data[0][$field];

        // now do something with the primary key
        //.....
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Filter values of fields depending on other fields
Next Topic: Use the ADD5 template
Goto Forum:
  


Current Time: Tue Nov 26 02:25:20 EST 2024

Total time taken to generate the page: 0.01128 seconds