Single page leveraging the file manager, file sets and attributes
Permalink 1 user found helpful
Greetings!
I am a new web dev learning the ropes of this awesome piece of software that is Concrete5.
I am going to try my hand at making a custom dashboard single_page that has a file manager and like two text fields, maybe these txt fields can be file attributes too
I need this instance of the file manager to auto add uploads to a pre-configured file-set and some file attributes.
What suggestions can a newbie get to accomplish this seemingly simple task?
Thanks in advance!
I am a new web dev learning the ropes of this awesome piece of software that is Concrete5.
I am going to try my hand at making a custom dashboard single_page that has a file manager and like two text fields, maybe these txt fields can be file attributes too
I need this instance of the file manager to auto add uploads to a pre-configured file-set and some file attributes.
What suggestions can a newbie get to accomplish this seemingly simple task?
Thanks in advance!
Ok. I can upload the file, assign it to a file set and it gets the attributes assigned to the fileset. How do I go about the task of adding a value to that attribute?
I only have the file upload field in my form, but I want to add a text field to fill the text attribute i got for this file set attribute.
So far, my attempts have yielded errors.
Here is my file upload controller function:
I only have the file upload field in my form, but I want to add a text field to fill the text attribute i got for this file set attribute.
So far, my attempts have yielded errors.
Here is my file upload controller function:
$pathToFile = $_FILES['fileUp']['tmp_name']; $nameOfFile = $_FILES['fileUp']['name']; $fObj = $this->fi->import($pathToFile, $nameOfFile); if(is_object($fObj)){ Loader::model('file_set'); $fs = FileSet::createAndGetSet("Files",FileSet::TYPE_PUBLIC); $fs->addFileToSet($fObj); //this bit i know its wrong - producing sql errors about fID not being set... no idea how to tackle it // Loader::model('file_version'); // $fv = new FileVersion(); // $attribute = FileAttributeKey::getByHandle('file_id'); // $fv->setAttribute($attribute, $this->post('fileID')); } $this->redirect('/dashboard/spHome/single_page', 'successfully_uploaded');
[SOLVED]
What I did is that I replaced commented code in previous post with the following code:
Also in the controller I added the file helper to the on_start method, I am not sure if that was required for the success of this little thing here, but since it is working I will stick to the golden rule of "if it ain't broken - don't fix it" and move on lol
This has been fun, documenting my questions here lol.
What I did is that I replaced commented code in previous post with the following code:
if($fObj instanceof FileVersion){ $fv = $fObj; $fID = $fv->getFileID(); $ak = "attrib_handle"; $value = $this->post("formFieldName"); $fv->setAttribute($ak,$value); }
Also in the controller I added the file helper to the on_start method, I am not sure if that was required for the success of this little thing here, but since it is working I will stick to the golden rule of "if it ain't broken - don't fix it" and move on lol
This has been fun, documenting my questions here lol.
That helped me with the controller code, and this helped me around the dashboard single_page:http://www.altinkonline.nl/tutorials/concrete5/make-a-concrete5-sin...
I found that both things could be easily combined, so I did.
I was able to answer my questions and get pretty useful sample code to boot! I'll keep watching those video training sessions for sure!