Download file from filestore

65 views
Skip to first unread message

Riccardo Lorini

unread,
Apr 18, 2012, 5:35:23 AM4/18/12
to agile-too...@googlegroups.com
Hi,
i create a simple model with name, text and one file , that i insert using the crud and filestore funcionalities.

This is the model code :

class Model_Batch extends Model_Table {

public $entity_code='batch';
    public $table_alias='ba';
    function init(){
        parent::init(); 

        $this->addField('name');
$this->addField('description');

 $this->addField('batch_file')->refModel('Model_Filestore_File')->displaytype('file');

    }

Now my question is :  How can i download or show the file in an MVCgrid ? 
Actually the MVCgrid shows me the file ID , i need to connect the name with the file.

Thank you

Janis Volbergs

unread,
Apr 18, 2012, 5:42:31 AM4/18/12
to agile-too...@googlegroups.com
HI,

One way:

class MyGrid extends Grid {
function init(){
$this->fm = $this->add("filestore/Model_File");
}
function formatRow(){
parent::formatRow();
$this->fm->load($this->current_row["batch_file"]);

$src = $this->fm->getPath();
$name = $this->fm->get("name");

$this->current_row_html["batch_file"] = "<a href='$src'>$name</a>";
}
}

then use in page $this->add("MyGrid");


n.b. above is for 4.2
p.s. not parsed.

--
FYI: If amount of emails you receive from this group is too much - switch to "Digest" mode. You'll receive no more than 1 email per day.
 
To post to this group, send email to
agile-too...@googlegroups.com
 
To unsubscribe and view archive:
http://groups.google.com/group/agile-toolkit-devel?hl=en
 
To download Agile Toolkit, visit:
http://agiletoolkit.org/

Riccardo Lorini

unread,
Apr 19, 2012, 1:32:18 PM4/19/12
to agile-too...@googlegroups.com
Thank you very much for your answer, i finally reach the file download!!

I discover agile tookit from few week but i think is really smart!!

Now i'll fight with the export of a MVCgrid ... i think there is something that goes wrong!! :)

Regards
Riccardo

Janis

unread,
Apr 19, 2012, 1:40:00 PM4/19/12
to agile-too...@googlegroups.com, agile-too...@googlegroups.com
Yes, export controller is outdated and not tested with 4.2

I am planning to rewrite it to make it more efficient and to take advantage of 4.2 features

Cheers
Reply all
Reply to author
Forward
0 new messages