This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

martinjuniors
martinjuniors

I'm sure this is very simple but it's proving just a bit beyond me at the moment.

I have made a plugin that I would like to use for displaying galleries which is working fine. However, trying to add the options of the galleries that I have created in my component is proving to be difficult.

When I add the component to a page, I have now got the option to choose all the galleries that I created but displaying the gallery based upon which one I selected is what I have been unsuccessful in doing.

Any help would be greatly appreciated!

I'm sure this is very simple but it's proving just a bit beyond me at the moment.

I have made a plugin that I would like to use for displaying galleries which is working fine. However, trying to add the options of the galleries that I have created in my component is proving to be difficult.

When I add the component to a page, I have now got the option to choose all the galleries that I created but displaying the gallery based upon which one I selected is what I have been unsuccessful in doing.

Any help would be greatly appreciated!

Components/Gallery.php:

<?php namespace MartinSmith\Gallerys\Components;

use Cms\Classes\ComponentBase;
use MartinSmith\Gallerys\Models\Gallery as GalleryModel;

class gallerys extends ComponentBase
{
public $gallery;

public function componentDetails(){
    return [
        'name' => 'Frontend Gallery',
        'description' => 'A gallery for you webpage'
    ];
}

public function defineProperties() {
    return [
        'galleryName' => [
            'title' => 'Gallery',
            'type' => 'dropdown',
            'placeholder' => 'Select Gallery',
        ]
    ];
}

public function getGalleryNameOptions(){
        return GalleryModel::select('name')->orderBy('name')->get()->lists('name');
}

public function init(){
    $this->gallery = $this->loadGallerys();
}

public function loadGallerys(){
    $gallery = GalleryModel::where('name', '=', $this -> property('galleryName')) -> get();
    return $gallery;
}

}

Components/gallery/default.htm:

{% set gallerys = __SELF__.gallery %}

{% for gallery in gallerys %}

<div class="container-fluid px-0">

    <div class="gallery">

        <div class="row">

            {% for image in gallery.fullImage %}

            <div class="col-md-4 px-0 home-galleryImg">

                <a href="{{ image.path }}">

                    <div class="gallery-imgOverlay">
                        <p>{{ image.title }}</p>
                        <h5>{{ image.description }}</h5>
                    </div>

                    <img class="img-fluid" src="{{ image.thumb(650,auto) }}" alt="{{ thumbnail.description }}">

                </a>

            </div>

            {% endfor %}

        </div>

    </div>

</div>

{% endfor %}

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.