working on it ...

Filters

Explore Public Snippets

Sort by

Found 1 snippet

    public by markcl modified Aug 6, 2014  2473  1  6  0

    Add Image Gallery to Page

    <?php
    class PortfolioItem extends Page {
        private static $db = array(
            'TrailerVideoURL' => 'Text',
        );
    
        private static $has_many = array(
            'Still' => 'Image'
        );
    
        function getCMSFields() {
    
            $fields = parent::getCMSFields();
    
            $fields->addFieldToTab(
                'Root.Upload',
                $uploadField = new UploadField(
                    $name = 'GalleryImages',
                    $title = 'Upload one or more images (max 10 in total)'
                )
            );
            $uploadField->setAllowedMaxFileNumber(10);
    
            return $fields;
        }
    }
    class PortfolioItem_Controller extends Page_Controller {
    }
    
    class GalleryImageExtension extends DataExtension {
        private static $belongs_one_many = array('Galleries' => 'GalleryPage');
    }
    
    Image::add_extension('GalleryImageExtension');

    List Complete ( 1 snippet total )

    Cannot find what you were looking for?
    Ask the Snip2Code Community

    • Public Snippets
    • Channels Snippets