Gallery Manager extension

ok after a long time of setting up the code. I got it working somehow and I can see the image gallery on screen!

but i get the following message

Before add photos to product gallery, you need to save product

what shall I do now? pls see attached screenshot

It looks like you are tring to manage gallery of not existing product (model is not saved into database, so there is no gallery because there is no object where to attach it…)

The way how gallery behaviour is working is:

  • on a first save(after behaviour was added to model) it creates gallery, with provided configurations, for a model and saves its id in specified field

  • when you are rendering GalleryManager widged created gallery is used to load initial list of photo and to configure widget

  • after widget is renderd it can be used to manage gallery by "talking" to GalleryController using Id of an gallery

  • when model is deleted from database Gallery behaviour will remove related gallery and all images in it


About your question("what shall I do now?"):

  1. read the documentation, one more time

  2. look an example: https://bitbucket.org/z_bodya/yii-demo-blog

  3. look at extension source code - it is not too complicated, but this would make it much more clear - how extension works

  4. read topics in this thread - I believe, that almost every common issue is covered here.

  5. If you still have questions ask there, but please ask questions that can be answered(if do not understood something concreate, or want to achive something and need an advice, and so on… but not like this one (for me it sounds literally like: "I have done something weird. What shall I do next?")


About you comment on extension page:

http://www.yiiframework.com/extension/imagesgallerymanager/#c18038

Problem why that code is not working, is not about extension… it is because you are not understanding basic concepts how yii framework works: you should not call $this->widget from controller - you should do this in view that should be rendered using CController::render method, othervise widget would not be able to register styles and scripts using Yii::app()->clientScript

Better remove that comment from extension page - it is question, not a comment… it is not about an extension, it is completely useless for anyone…

Taking back all my comments!! Extension works fantastically! Thanks Bogdan

Hi Bogdan

In the controller action of Gallery Controller


/**

     * Method to handle file upload thought XHR2

     * On success returns JSON object with image info.

     * @param $gallery_id string Gallery Id to upload images

     * @throws CHttpException

     */

    public function actionAjaxUpload($gallery_id = null)

    {

        $model = new GalleryPhoto();

        $model->gallery_id = $gallery_id;

        $imageFile = CUploadedFile::getInstanceByName('image');

        $model->file_name = $imageFile->getName();

        $model->save();


        $model->setImage($imageFile->getTempName());

        header("Content-Type: application/json");

        echo CJSON::encode(

            array(

                'id' => $model->id,

                'rank' => $model->rank,

                'name' => (string)$model->name,

                'description' => (string)$model->description,

                'preview' => $model->getPreview(),

            ));

    }



Is the image stored on the server folder under gallery folder?

I checked that the image name is stored in the gallery_photo table but when I checked the gallery folder I see images but they are with different name…

Any idea how to save the images using your extension onto a specific directory in the server?

Image name


$model->file_name

is stored only for purpose of tracking uploaded filenames… it is not used to generate file name on the server or somewhere else…

Actual image is saved there:


$model->setImage($imageFile->getTempName());

Using id from gallery_photo.


Any idea how to save the images using your extension onto a specific directory in the server?

What exactly you want to do? In general you will need to modify extension.

Hello ,

I have read all the instruction steps but still i am unable to understand it please help me how to use this extention as i want to give functionality to create and add gallery imgaes . I am soory for being foolish but still i need to apply this extenion . Urgern :(

I dont understand what do you men by this

1.Checkout source code to your project, for example to ext.galleryManager.

2.Install and configure image component

5.Add GalleryController to application or module controllerMap.

6.Configure and save gallery model

regards,

versha

Юзал галерею для Yii 1, для Yii2 будет?

[size=3]Excuse Me, Sir.[/size]

[size=3] i have any question. for image component extension tar gz after extract, where the folder was placed and what the folder name ?? . Thanks[/size]

Excuse Me, Sir. I have tried the steps that have been given, but when it will be uploaded there was an error. how to handle it ? Help me, please. Thanks

Just finished porting to Yii2.

It is almost ready for use: