codem / DisplayAnything

A simple file and image gallery module for Silverstripe CMS
BSD 3-Clause "New" or "Revised" License
21 stars 5 forks source link

Problem installing the module #2

Open kumosal opened 12 years ago

kumosal commented 12 years ago

First of all thank you for sharing with us this great module. I followed your steps to install it, so I created a GalleryPage.php and a GalleryPage.ss filled with the example you provided, now when I create a new GalleryPage Pgae type it shows a blank area; no tabs for Gallery or video gallery..

Can you tell me what I am missing here?

regards

MrJamesEllis commented 12 years ago

Hi, thanks for the feedback - can you provide the code you are using and any error messages... and did you run /dev/build ? You don't need a specific page - it'll run on any page provided the data schema is set up correctly.

I set the module up on a current site a few days back and it worked ok so I'm thinking it's a setup issue or a bug in the instructions.

Thanks James

MrJamesEllis commented 12 years ago

I just pushed an update to the readme.md with some documentation fixes, review the diff here: https://github.com/codem/DisplayAnything/commit/75edc38f3b4f12534745696e6867ee048a8d9e11

you may have included some of the incorrect documentation in your own GalleryPage?

kumosal commented 12 years ago

I created a new class based on the new code you provided and I changed the name from MyPage to MediaPage and renamed the subdirectory for uploads. run dev/build?flush=1.. the database fields are successfully added to the database. Then when I create a page of MediaPage type, a blank page shows with no fields and no errors.. I'm trying to megrate from ImageGallery module to this module, and when I click on the Image Gallery page I don't see any migration tab there..am I missing something here?

MrJamesEllis commented 12 years ago

If you are getting a blank page there may be a syntax error. Try upping the error reporting (display_errors) and ensure SS is in dev mode in _config.php (Director::set_environment_type('dev');

If you are missing the migration tab then try updating your copy of the module - there was a regression issue in the migration that was fixed in https://github.com/codem/DisplayAnything/commit/d7cedd697a7ec18abb7b13414ecf1c9eb5ae09fe - if you had removed the ImageGallery module but left the tables in place in the database then the tab would (incorrectly) not appear.

Those three points in that diff will explain when the tab won't appear.

Hope that helps.

MrJamesEllis commented 12 years ago

I'm closing this issue as there has been no update. Please try the latest master for DisplayAnything, it may resolve any continuing issue.

mrcl commented 12 years ago

First of all, thanks for the module. It looks very nice. However I did not get it working properly. Could someone help me?

I have installed DisplayAnything and created the PHP classes and SS Templates as recommended.

GalleryPage.php

<?php class GalleryPage extends Page {

    public static $has_one = array(
            'SomeFile' => 'UploadAnythingFile',
            'SomeGallery' => 'DisplayAnythingGallery',
            'SomeVideoGallery' => 'DisplayAnythingYouTubeGallery',
    );

    public function getCmsFields() {
            $fields = parent::getCmsFields();

            //GALLERY per page
            $gallery = new DisplayAnythingGalleryField(
                    $this,
                    'SomeGallery',
                    'DisplayAnythingGallery'
            );
            $gallery->SetTargetLocation('/Gallery');//relative to ASSETS_PATH
            $fields->addFieldsToTab('Root.Content.Gallery', array($gallery));

            //SINGLE field - with a test to see if the page has been saved
            //NOTE: that single field uploads can be done with the core Silverstripe FileField (and is probably more stable at this point)
            if(!empty($this->ID)) {
                    $uploader = new UploadAnythingField($this, 'SomeFile','File');
                    $uploader->SetMimeTypes(array('text/plain'));//this single file uploader only allows plain text uploads
            } else {
                    $uploader = new LiteralField("PageNotSavedYet", "<p>The file may be uploaded after saving this page.</p>");
            }
            $fields->addFieldsToTab('Root.Content.Image', array($uploader));

            //YOUTUBE VIDEO gallery - a simple extension to the default gallery
            $gallery = new DisplayAnythingGalleryField(
                    $this,
                    'SomeVideoGallery',
                    'DisplayAnythingYouTubeGallery'
            );
            $gallery->SetTargetLocation('videogallery');
            $fields->addFieldToTab('Root.Content.Videos', $gallery);

            return $fields;
    }

}

class GalleryPage_Controller extends Page_Controller {

} ?>

GalleryPage.ss # gtihub is breaking the code bellow

<% if SomeImageGallery %> <% control SomeImageGallery %>

$Title

<% if GalleryItems %>
<% end_if %> <% include Clearer %>

<% end_control %> <% end_if %>

After executing dev/build?flush=1 The database tables were created and finally I can Fing the GalleryPage type within the CMS.

Then I created the Page, which presents three new tab Gallery | Image | Videos As expected.....

Here I get some Issues. Once the page was saved I could upload my pictures using the drag and drop tool, as choosing the files through the file selector window. But that could only be done in the Gallery Tab, when I do the same in the Image tab... nothing happens!!! The Video tabs works as well, but It is possible to select any file type to upload there. Is there anyway to restrict it? That applies to the Image Gallery as well.

The last and main problem is that I get no results in the WebSite page when I try to visualize that on the browser. It seems that the SomeImageGallery control does not return anything. Just to ensure that the template was being accessed properly I out a random string on the top of the GalleryPage.ss file, what was returned when clicking on the page.

What could be the problem here?

Cheers

MrJamesEllis commented 12 years ago

Difficult to know what's going on but the sample page and templates are/were there for a guide only, copying and pasting them may work for some and not for others.

To help out, I've created an examples directory with some example pages, layouts and a dataobject example. Have a look at that and used them as a guide.

There were a couple of syntax errors in the original single file example from the readme, specifically the SetMimeTypes() method call during setup. ex implementation that works: https://github.com/codem/DisplayAnything/blob/master/examples/pages/SingleImagePage.phps

Worth noting that the single file implementation is functionally the same as the core Silverstripe FileField, except you can drag and drop one file onto this field :)

Hope that helps you out.

mrcl commented 12 years ago

Hey Really Awesome Dude!!!

Works smoothly... I will go through the code to understand how it works!!! By now I've gotten what I wanted...

If I find anything else, I will let you know.

Cheers