Jump to content


Photo

Module: Manage Files

Module

  • Please log in to reply
28 replies to this topic

#1 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 809 posts
  • 401

  • LocationBerlin, Germany

Posted 12 November 2011 - 02:54 PM

Hi,
I didn't like the way how ProcessWire works with files right now. So I thought it's time for an Module which makes it better. Right now the module isn't finished but I'm working on it (probably together with Soma).

My goal is to create an module which let's you mange all of your files and images easy and let you upload files which aren't connected to a page so that every page can use it.

If you have wishes or ideas for this module you can post them here. (Also if you know a better way to solve this)

And by the way here's a first screenshot (I started today, so it isn't that great right now).

UPDATE:

Download: https://github.com/N...oll/ManageFiles

Attached Thumbnails

  • Bildschirmfoto 2011-11-12 um 20.54.08.png

Edited by Pete, 23 March 2012 - 03:29 PM.


#2 Soma

Soma

    Hero Member

  • Moderators
  • 5,057 posts
  • 3821

  • LocationSH, Switzerland

Posted 12 November 2011 - 03:01 PM

I would like to know a little more about your plans.

Not sure if you seen my edit on your other thread showcase you site. I copied it to here:

---
For your problem in managing images. Reading again you post, you want to have images in one place and select them on different pages? Or what are you needs here exactly?

There's a simple way to archive something like this:

Have an external section "files" where you upload images. But each image a separate page. Have a template "image" and add a single image field and may even more fields imaginable.

So you could add a Page reference field "selected_image" that is set up to select from the section and only the "image" template. Add this field to your pages templates. Now you can select images/image using this field. You can manage images in one location and select it on each page. If you upload and replace an image the reference will not get lost, so this is a great solution.

In the php template you would output the image using:

<?php

// if single page reference 
echo $page->selected_image->image->url;

// if multiple page reference select
foreach($page->selected_image as $img){
    echo $img->image->url;
}

You even can select in TinyMCEs image PW dialog (select page, and chose image from that page), but this will add a path to the file and not an id reference, (which is my biggest problem with that approach).

Though as long as you use it for out of TinyMCE content on page it's a great solution to have more control. It's also possible with a little hack (untill Ryan implemented this) to show a thumbnail in the page list select, if the label of the template is an image field (in template advanced setting available). Look this thread of mine: http://processwire.c...opic,411.0.html

@somartist | modules created | support me, flattr my work flattr.com


#3 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 809 posts
  • 401

  • LocationBerlin, Germany

Posted 12 November 2011 - 03:11 PM

Yeah, I read your answer but I thought if I open this topic it's like an answer.

I think that you shouldn't create a separate page for each picture (I mean I've got more than 2000 images and files so it would be kind of confusing).

(By the way is there a way to chat with you like Facebook or Twitter?)

#4 Soma

Soma

    Hero Member

  • Moderators
  • 5,057 posts
  • 3821

  • LocationSH, Switzerland

Posted 12 November 2011 - 03:15 PM

Sure I added you on both :)

@somartist | modules created | support me, flattr my work flattr.com


#5 apeisa

apeisa

    Hero Member

  • Moderators
  • 3,154 posts
  • 1705

  • LocationVihti, Finland

Posted 12 November 2011 - 03:33 PM

Great stuff Nico.

As a side note: our old cms had very similar file management to pw: you add files to any page and the do cross references to those. It works fine on most cases, but sometimes it is just easy to "lost" files for clients ("well.. I don't remember where I put it"). It will be great to have central repo for files (but still keep page relationship).

What I would love to have regarding file management is more meta tags for files (tags). This is easy if you go one file per page route - but to be honest - it is clumsy way here. Imagine uploading 50 files that way comparing current ajax way or even old dynamic form method...

#6 Oliver

Oliver

    Sr. Member

  • Members
  • PipPipPipPip
  • 134 posts
  • 27

  • LocationBasel, Switzerland

Posted 12 November 2011 - 04:36 PM

Would love to have the possibility to manage "assets" like files / images in an own manager interface. File or image fields of pages could be linked with directories in the asset manager, so there wouldn’t be a conflict between centralized and page related approach.

#7 Soma

Soma

    Hero Member

  • Moderators
  • 5,057 posts
  • 3821

  • LocationSH, Switzerland

Posted 13 November 2011 - 11:09 AM

I'm trying to help Nico a little on this. And I think we reached a major problem concerning how this should work.

I was chatting with Nico last night and he showed me his current module. It's was mainly reading the assets files dir to glob all files and in relation to the folder id delete them with manual sql from the field table. This show's all files (including thumbs) of each file and it has some limitations.

I thought it may possible to make this using API and scan all templates for FieldtypeFile fields and do a find over all pages using those templates. Then iterate through them and list all files depending what type it is output a preview or link to the file. It works fine so far but I got problems getting the delete of the file to work on the page it is located through API. Anyway that's not the main issue.

Now major problem is how to expand this with filtering and per branch in the tree and get a pager working, since it's returning pages with various files attached... the pager can't possibly be on the pages found but should be on the files found instead. I don't see an easy way to get this all running and having filtering (per page or pages, filetype etc) or search function possibly.

So my question is what features would be needed and how could it possibly be done. I reach a major wall here I can't decide what would be best way to go. Many traps here I think.

Attached the current rough proof of concept module. It installs a "Files" page after "Pages", and it shows files (no thumbs) and a pager which doesn't work correctly. Also deleting doesn't work, but it's just to give an example.

Attached Files


@somartist | modules created | support me, flattr my work flattr.com


#8 Oliver

Oliver

    Sr. Member

  • Members
  • PipPipPipPip
  • 134 posts
  • 27

  • LocationBasel, Switzerland

Posted 14 November 2011 - 12:34 PM

I had a quick look at the data model in the db associating the files with their pages. I haven’t tested your plugin, yet, but I think, it would be nice to let the user navigate through files by treating the page structure and file fields like directories. Similar to the url paths. And with the possibility to directly upload files into those "virtual" directories.

#9 nikola

nikola

    Sr. Member

  • Members
  • PipPipPipPip
  • 233 posts
  • 137

  • LocationZagreb, Croatia

Posted 01 February 2012 - 02:28 PM

Nico & Soma,

any chance of further developmnet of this plugin? Deleting images through file manager would be quite nice.

Thx
Check out my ProcessWire admin themes: Futura Remixed Admin Theme / Moderna Admin Theme / Futura Admin Theme

#10 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 809 posts
  • 401

  • LocationBerlin, Germany

Posted 01 February 2012 - 05:37 PM

Working on it :)

#11 Soma

Soma

    Hero Member

  • Moderators
  • 5,057 posts
  • 3821

  • LocationSH, Switzerland

Posted 01 February 2012 - 05:41 PM

Hey, almost forgot about it, but only almost. I recently just was thinking about this one, great to hear you're working on it Nico. Unfortunately I got so much up with higher prio, I need to catch up first before I could spend more time on this.

@somartist | modules created | support me, flattr my work flattr.com


#12 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 809 posts
  • 401

  • LocationBerlin, Germany

Posted 01 February 2012 - 06:48 PM

Tadam: https://github.com/N...oll/ManageFiles

#13 diogo

diogo

    Hero Member

  • Moderators
  • 2,897 posts
  • 2302

  • LocationPorto, Portugal

Posted 01 February 2012 - 07:32 PM

works perfectly Nico!

edit: although it tells me that all files are 0MB. Should be measured in KB maybe

#14 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 809 posts
  • 401

  • LocationBerlin, Germany

Posted 01 February 2012 - 10:12 PM

Great to hear and thanks for sharing the mistake. Uploaded a fixed version to github. :)

#15 nikola

nikola

    Sr. Member

  • Members
  • PipPipPipPip
  • 233 posts
  • 137

  • LocationZagreb, Croatia

Posted 02 February 2012 - 12:26 AM

Thanks a lot Nico! Works as expected. Nice job, quick as always ;)
Check out my ProcessWire admin themes: Futura Remixed Admin Theme / Moderna Admin Theme / Futura Admin Theme

#16 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 02 February 2012 - 09:47 AM

Nice module Nico! I have a few suggestions:

1. The current way you are using $pages->find() to find files is going to mess up the pagination for any pages that have blank file fields. For instance, on the site I tested, I have 30 files, but hundreds of pages with blank file fields. I ended up with 90+ pagination links, where most pages were just blank. So I think that finding files by template is probably not ideal. Instead I'd suggest finding them by field. This will work:

$fields = $this->fields->find('type=FieldtypeFile|FieldtypeImage')->getArray();
$pages = $this->pages->find(implode('|', $fields) . ">0, sort=-modified, limit=10");

2. You have some stray var_dump() functions that are breaking the display in some parts of the module.

3. In your executeDelete(), I don't understand why you have this line:

foreach($f->page->getInputfields() as $field) {

It doesn't seem necessary? I would get rid of it if you can.

#17 Soma

Soma

    Hero Member

  • Moderators
  • 5,057 posts
  • 3821

  • LocationSH, Switzerland

Posted 02 February 2012 - 02:39 PM

Nice module Nico! I have a few suggestions:

1. The current way you are using $pages->find() to find files is going to mess up the pagination for any pages that have blank file fields. For instance, on the site I tested, I have 30 files, but hundreds of pages with blank file fields. I ended up with 90+ pagination links, where most pages were just blank. So I think that finding files by template is probably not ideal. Instead I'd suggest finding them by field. This will work:

$fields = $this->fields->find('type=FieldtypeFile|FieldtypeImage')->getArray();
$pages = $this->pages->find(implode('|', $fields) . ">0, sort=-modified, limit=10");


Aaaand I was waiting for this answer since 2 months :P as I wrote a lengthy post back then about this issue above in this thread asking how this issue could be solved... Think you must have missed it then :D

@somartist | modules created | support me, flattr my work flattr.com


#18 slkwrm

slkwrm

    Sr. Member

  • Members
  • PipPipPipPip
  • 317 posts
  • 185

  • LocationTallinn, Estonia

Posted 02 February 2012 - 05:23 PM

Great work, Nico. Gonna check it out as soon as I have time. And I need to find a way to collect and categorize all this cool little snippets Ryan's posting here :)

#19 Nico Knoll

Nico Knoll

    The Boss.

  • Members
  • PipPipPipPipPip
  • 809 posts
  • 401

  • LocationBerlin, Germany

Posted 03 February 2012 - 06:55 AM

OK, new version is up (fixed point 1 and 2 of Ryan's).

@Ryan: (Point 3) I need this to find the "InputfieldFiles" and the "InputfieldImages", I guess...

#20 ryan

ryan

    Reiska

  • Administrators
  • 7,797 posts
  • 6572

  • LocationAtlanta, GA

Posted 03 February 2012 - 09:56 AM

Nico, I guess the question is then, why do you need those Inputfields? :) I can't figure out why they are necessary there.





Also tagged with one or more of these keywords: Module

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users