Not signed in (Sign In)

Wildflower IRC: Connect to the server at irc.freenode.net, and then join the channel #wildflower - Your Host is Tecknix :)

  1.  
    Hey

    My client has pointed out that the uploaded files all become a little disorganised and messy after uploading a large amount. And I would have to agree with them - they've uploaded 132 files, and it's hell trying to find exactly what you want! There's 12 different pages to search through to find an image or file.

    I was wondering if anybody has done anything special in order to better organise things. I mean, the obvious thing would be the ability to organise the uploaded files into 'folders' or categories. I guess another way would be to filter it by file type - e.g. Document, Image, etc.

    A search feature would also be nice to see... but again, it's a case of implementing it into the code. The only problem with this would be if the uploads had not been renamed from their default - e.g. IMG_0001.jpg. This filename isn't very descriptive, so they'd have to know the exact filename to be able to find what they want.

    So, yeah. What have other people done in order to improve things on the organisation front?
    My client would like me to add some form of organisation to the files, so I'm going to have to get knee-deep in PHP & JS code again.

    I was just wondering if anybody had any pointers or PHP/JS snippets that would help me along my way? Rest assured that I would love you forever if you could help me somehow!!

    Cheers

    Oliver
    •  
      CommentAuthormajic
    • CommentTimeJan 23rd 2010
     
    This is a sore point of wf currently, I think this could be resolved

    I have tried and failed to make assets work with subfolders. Tecknix has worked on a system of tagging asset files, this code has not been pushed to github yet. This is to make a gallery feature (a gallery is made up of images belonging to a tag)

    I think if wildflower allowed you to create virtual containers & allowed you to rename files (override them in upload)
    and then if you could drag and drop these files to these virtual containers - management of assets would be easier

    Also if the admin_index view of assets allowed the display of assets to be filtered that would be great, next the insert image could better handle files of different types.

    Assets can be any filetype - but only images can be inserted into content. Take a pdf for example this should be insertable as a link -
    non image assets would mostly be text links to the file
  2.  
    Okay...

    Well I've been trying bloody hard for the past few hours to get something together, just some form of organisation. It's going to be hacky and nasty.
    I'll let you know how I get on with it.

    I'm going to add the ability to put files into categories. It won't be drag & drop, nothing fancy. I don't want to make it harder for myself that it already is ;-)

    Although, drag & drop would be an EXCELLENT addition for future additions of Wildflower..
    • CommentAuthorTeckniX
    • CommentTimeJan 25th 2010
     
    @Oliver Treend
    I'm still working on a good fix to make it completely dynamic, aka creating an assets category and listing all the different children for it.

    Right now I simply hard coded the following:

    In wildflower/views/wild_assets/_upload_file_box.ctp - update the category array:


    $form->input('category', array('label'=>'Category:', 'type'=>'select','options'=>array('image'=>'image','avatar'=>'avatar','gallery'=>'gallery'),'default'=>$filter)),


    In wildflower/views/wild_assets/index.php - update the sidebar in the "$partialLayout->blockstart('sidebar')" section:


    <li class="sidebar-box">
    <h4>Filter by Category:</h4>
    <?php $fileCategories = array('image'=>'Image','avatar'=>'Avatar','gallery'=>'Gallery'); ?>
    <ul>
    <li><?php echo $htmla->link('All', array('action' => 'index')); ?></li>
    <?php foreach($fileCategories as $filterIndex=>$fileCategory): ?>
    <li><?php echo $html->link($fileCategory,"/".Configure::read('Wildflower.prefix')."/assets/index/".$filterIndex) ?></li>
    <?php endforeach; ?>
    </ul>
    </li>


    In wildflower/controllers/wild_assets_controller.php - modify the following methods:


    /**
    * Files overview
    *
    */
    function wf_index($filter=null) {
    if($filter){
    $this->paginate = array(
    'conditions' => array('WildAsset.category' => $filter),
    'limit' => 12,
    'order' => array('created' => 'desc')
    );
    }
    $this->feedFileManager($filter);
    }



    private function feedFileManager($filter) {
    $this->pageTitle = 'Files';
    $files = $this->paginate($this->modelClass);
    $this->set(compact('files','filter'));
    }


    That should help 'filter' some of the unwanted files. It's not perfect, but it works :)

    ps: sorry for the ugly formatting my textile format of bc. didn't work.
  3.  
    @TeckniX: You are a God! Works like a charm. I would like to work on making the categories dynamic... but that shouldn't be too hard to hack around.
    Cheers!!
    •  
      CommentAuthormajic
    • CommentTimeFeb 1st 2010
     
    This seems nice too me

    I am looking into this now with some some other nice spin-offs in mind too. Tagging of file content

    plus interface controls for it to -- part2 of asset management - I have merged asset management into my
    master branch not yet pushed it since I am working on part2 (expect to push part1 this eve if not shortly after)

    Its managing 200+ files :)

    Thinking about part3 too!
    • CommentAuthorTeckniX
    • CommentTimeFeb 16th 2010
     
    A quick update to all of this.

    I managed to get the dynamic categories to work. This has been pushed to my branch. The only caveat to this, is that the code depends on the category Asset to be @ ID = 61 in the DB. Not too big of an issue, since a similar setup is in place to detect the homepage. Perhaps it should become a setting in the backend too?

    On to the code - this is in the latest wf from github, which is without the wf_ prefix.

    Setup the models -
    In the wildflower/models/category.php - add:

    public $hasMany = array('Asset');


    In the wildflower/models/asset.php - add:

    public $catParent = 61;

    public $belongsTo = array('Category'=>array(
    'conditions'=>array('Category.parent_id'=> 61)
    )
    );



    Above you can update the 61 to be what the category is for you, if you've updated

    In the wildflower/controllers/asset_controller.php - modify:

    private function feedFileManager($filter=null) {
    // Categories for select box
    $categories = $this->Asset->Category->find('list', array('fields' => array('id', 'title'), 'conditions' => array('Category.parent_id' => $this->Asset->catParent)));
    $this->pageTitle = 'Files';
    $files = $this->paginate($this->modelClass);
    $this->set(compact('files','filter','categories'));
    }

    and just like above in the old wf_ code:

    function admin_index($filter=null) {
    if($filter){
    $this->paginate = array(
    'conditions' => array('Asset.category_id' => $filter),
    'limit' => 12,
    'order' => array('created' => 'desc')
    );
    }
    $this->feedFileManager($filter);
    }

    and

    function admin_edit($id) {
    $this->data = $this->Asset->findById($id);
    $this->pageTitle = $this->data[$this->modelClass]['title'];
    $categories = $this->Asset->Category->find('list', array('fields' => array('id', 'title'), 'conditions' => array('Category.parent_id' => $this->Asset->catParent)));
    $this->set(compact('categories'));
    }

    don't forget to update the 'save' code so that everything gets saved:

    function admin_update() {
    $this->Asset->create($this->data);
    if (!$this->Asset->exists()) return $this->cakeError('object_not_found');
    $this->Asset->save();
    $this->redirect(array('action' => 'edit', $this->Asset->id));
    }


    You now need to create the dynamic dropdown - in wildflower/views/assets/admin_index.ctp - add:

    <span style="color: rgb(102,102,102); font-size: 10px;">Category: <?php echo $file['Category']['title']; ?></span>

    below the <h3><?php echo $html->link($label, array('action' => 'edit', $file['Asset']['id'])); ?></h3> to display the category the file belongs to and

    <li class="sidebar-box">
    <h4>Filter by Category:</h4>
    <ul>
    <li><?php echo $htmla->link('All', array('action' => 'index')); ?></li>
    <?php foreach($categories as $filterIndex=>$fileCategory): ?>
    <li><?php echo $html->link(ucfirst($fileCategory),array('action' => 'index',$filterIndex)) ?></li>
    <?php endforeach; ?>
    </ul>
    </li>

    to the $partialLayout->blockStart('sidebar') section, paste if after the first
    <li class="sidebar-box">

    Modify the wildflower/views/assets/_upload_file_box.ctp - add:

    $form->input('category_id', array('label'=>'Category:', 'type'=>'select','options'=>$categories,'default'=>$filter)),

    after the
    $form->input('file', array('type' => 'file', 'between' => '<br />', 'label' => false)),
    This will add the dropdown on the upload form.
    Don't forget to also modify the wildflower/views/assets/admin_edit.ctp
    $form->input('category_id', array('label'=>'Category:', 'type'=>'select','options'=>$categories)),
    This will allow you to update the category an asset belongs to.


    You should now be able to add all the categories you want all through the backend!

Wildflower CMS is the creation of Klevo
the Wildflower Logo was created by Oliver Treend