Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » HasManyFileManager: New CMS module/extension. Testers/review needed

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2 3 4 5 6 7 8
Go to End
Author Topic: 104010 Views
  • vstrazz
    Avatar
    Community Member
    63 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    First off, Banal thank you. This is a great addition to silverstripe. Thank you for your hard work.

    I installed this mod on a development site, and it worked fine. I went to install this on a live production site soon after and encountered some errors.

    I think I have narrowed down the errors to having something to do with the ecommerce module. The development site I initially installed this on did not have ecommerce but once I put ecommerce on there, I received the same errors that I received on the other site.

    this is the debug output.

    FATAL ERROR: DATABASE ERROR: Couldn't run query: SELECT `File`.ID, `File`.ClassName, `File`.Created, `File`.LastEdited, `File`.Name, `File`.Title, `File`.Content, `File`.ParentID, `File`.Filename, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName, `File`.PopupWidth, `File`.PopupHeight, `File`.Embed, `File`.LimitDimensions FROM `File` LEFT JOIN `Product_Image` ON `Product_Image`.ID = `File`.ID WHERE (File.SiteTreeID = 8) AND (File.Grouping = 'MyImages') ORDER BY Grouping, Sort | Column 'Grouping' in order clause is ambiguous
    At line 431 in /var/www/vhosts/mysite.com/subdomains/dev/httpdocs/sapphire/core/model/Database.php

    any ideas?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    @vstrazz
    There seems to be a conflict between the File Table and the Product_Image Table. Both seem to have a Grouping field.
    I changed my code, so that it's no longer ambiguous.

    You can get the updated code from SVN or just replace Line 15 of filemanager/code/SiteTreeFileHandler.php with the following line:

    public function AttachedFiles($group = '', $sort = 'File.Grouping, File.Sort'){

    Hope that helps!

  • vstrazz
    Avatar
    Community Member
    63 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Thanks Banal, my apologies if this was discussed earlier in the thread and I missed it. I am extending this module to be able to show random uploaded images and link each image to the sponsor page. This made it tons easier.

  • banal
    Avatar
    Community Member
    901 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Don't apologize. This was an issue i wasn't aware of and i fixed it right now, after you posted the problem.
    I hope you post a link to the site, once it's done so we can all enjoy

  • vstrazz
    Avatar
    Community Member
    63 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Don't apologize. This was an issue i wasn't aware of and i fixed it right now, after you posted the problem.
    I hope you post a link to the site, once it's done so we can all enjoy

    Cool, I helped out! :-D

    Will do. I got the random image working with your module, and it handles the link to image relationship as well. pretty easy. If anyone would like to see the code just let me know.

    Thanks again Banal

  • Tyndie
    Avatar
    Community Member
    9 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Hi,

    I would like to be able to attach pdf's to a type 'page' which will have an article, but have the pdf's upload to a certain folder which has already been created.

    Is this possible?

  • banal
    Avatar
    Community Member
    901 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    @Tyndie

    If you want to upload just one pdf per page, you don't really need the HasManyFileManager and you could simply use the FileField (or FileIFrameField) Class. By setting the last parameter of the constructor, you can change the upload folder for the file.

    If you need multiple files per page, you can use the HasManyFileManager, but you have to change some things in order to get your files created in the desired folder.
    You can change the base folder in the file AttachedFile.php on line 76

    static $baseFolder = 'Uploads/AttachedFiles';


    Whenever you create a HasManyFileManager you also specify a name, that is used for file grouping. This also creates a subfolder where files belonging to that group are being stored. You should consider this behavior too!

    Example: If you need your files to be in Uploads/PDF, you should set the $baseFolder to 'Uploads' and the group name of the HasManyFileManager to 'PDF'.

    Hope that helps.

  • Tyndie
    Avatar
    Community Member
    9 Posts

    Re: HasManyFileManager: New CMS module/extension. Testers/review needed Link to this post

    Is there anyway of overriding the upload folder in the pagetype:

    For example this is my page type:

    <?php

    class Screening extends Page {
       static $db = array(
       );
       
       static $has_many = array(
       'Files' => 'File',
       );
       
       function getCMSFields() {
       $fields = parent::getCMSFields();
       static $baseFolder = 'Uploads/Programme-Notes/Season-2008-2009';
    $manager = new HasManyFileManager(
    $this,
    'PDF', // name -> will be used for file grouping
    'Files' // relation name defined in $has_many
    );
    // creating tab for the "Files" Manager
    $fields->addFieldToTab('Root.Content.Files', $manager, $baseFolder);

             
        return $fields;
       }
       //static $icon = "tutorial/images/treeicons/news";
       public function onBeforeDelete(){
    parent::onBeforeDelete();
    $this->deleteAttachedFiles();
    }

    }

    class Screening_Controller extends Page_Controller {

    }

    ?>

    I also have a gallery page for all programme notes by season, which is why I would like to specify where the files will go. Sometimes there will be more than one file, maybe images too.

    104010 Views
Page: 1 2 3 4 5 6 7 8
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.