Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features and status #1

Closed
viktor-zhuromskyy opened this issue Apr 15, 2016 · 4 comments
Closed

Features and status #1

viktor-zhuromskyy opened this issue Apr 15, 2016 · 4 comments

Comments

@viktor-zhuromskyy
Copy link

Would you be so kind to update your readme.md with features set and status of the extension, please?

@letunhatkong
Copy link

letunhatkong commented May 5, 2016

I downloaded this extension and try test on my local.
This extension created Gallery Module on content section of M2 admin. It includes 2 sections: Galleries, and Images.

  • Images: allow user create images with name, url, image, description, status (enable or disable)
  • Gallery: allow user create galleries with name, status (enable or disable), collection (filter all images and user can select images to each galerry).

This extension is worked on Admin page. All data are stored on DB.
But i can't get galleries in front-end. :(

<?php
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$gallery = $_objectManager->get('DR\Gallery\Block\Gallery');

$a = $gallery->getGallery(); // Not work
echo $this->getGallery()->getId(); // Not Work
var_dump(count($a));
?>

@letunhatkong
Copy link

letunhatkong commented May 5, 2016

I created 2 function.
File ../Block/Gallery.php

/**
     * Get Gallery Collection (status = 1)
     * @return mixed Gallery Collection
     */
    public function getGalleryCollection()
    {
        $result = [];
        $galleries = $this->galleryRepository->getAllGallery();
        if (is_null($galleries) || count($galleries) <= 0) return [];
        foreach($galleries as $gallery) {
            $_gal = [
                'id' => $gallery->getId(),
                'name' => $gallery->getName(),
                'status' => $gallery->getStatus(),
                'images' => []
            ];
            $images = $gallery->getImageCollection();
            if (count($images) > 0) {
                $_img = [];
                foreach ($images as $image) {
                    if ($image->getStatus()) {
                        $img = [
                            'id' => $gallery->getId(),
                            'name' => $gallery->getName(),
                            'path' => $image->getPath()
                        ];
                        array_push($_img, $img);
                    }
                }
                $_gal['images'] = $_img;
            }
            array_push($result, $_gal);
        }
        return $result;
    }

and file ../Model/GalleryRepository.php

/**
     * Get All Gallery with status = 1
     * @return mixed
     */
    public function getAllGallery() {
        return $this->galleryCollectionFactory->create()
            ->addFieldToFilter("status", "1")
            ->setOrder('updated_at', 'DESC');
    }

In Front - End

<?php
$_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$gallery = $_objectManager->get('DR\Gallery\Block\Gallery');
$galleries = $gallery->getGalleryCollection();
?>

@daniel-rose
Copy link
Owner

Sorry for the delay in getting back to you! @letunhatkong use the widget to display a gallery. @devdesco-ceo I will add the readme.md over the weekend.

@letunhatkong
Copy link

letunhatkong commented Jun 13, 2016

Thank Daniel Rose for this extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants