Giter Club home page Giter Club logo

c5_package_installer_utils's People

Contributors

jordanlev avatar mnkras avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

c5_package_installer_utils's Issues

Attribute Set helper functions

Hi Jordan...stellar work as always! Wish this had been around a few weeks ago when I was putting together my first package for the Marketplace-proper and trying to get my head around one or two of the more arcane things you can achieve with package installation!

Anyway, whilst I forked this repository and had a stab at making a couple of additions, my PHP prowess sort of failed me...figured it might be best to just describe a couple of cool little additions that you can probably figure out how to add into this class in your sleep!

In my Maximizer package I use the installer to create a new attribute set (a nifty, underrated new 5.5 feature) called 'Dashboard' and add my new 'maximize' select-type attribute to it. Involved a fair bit of trial and error and hitting the Concrete forums to achieve it so, if you think it would be a nice addition here and if my working code might help you, here it is! The key bits are obviously 'addSet' and 'setAttributeSet', and I don't think your installer utils currently have any methods that cover them and their use during package installation in any way.

I know...very selfish of me to push this forward, but I would certainly find it useful and so might yourself and others going forward as Attribute Sets start to become a little more widely-known and employed. Cheers!

private function installPkgAttributes($pkg) {

        // Install 'maximize' attribute (if doesn't already exist)
        Loader::model('collection_types');
        Loader::model('collection_attributes');
        Loader::model('attribute/categories/collection');   

        // Create an attribute set - called 'Dashboard' - to help avoid confusion with adding to pages. This attribute will obviously only do anything when assigned to dashboard pages

        // Check if attribute set already exists...if not, create it!
        $attrSet = AttributeSet::getByHandle('dashboard');
        if(!is_object($attrSet)){
            $eaku = AttributeKeyCategory::getByHandle('collection');
            $eaku->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE);
            $attrSet = $eaku->addSet('dashboard', t('Dashboard'), $pkg);
        }

        // Check if attribute already exists...if not, create it!
        $maximizeAttribute=CollectionAttributeKey::getByHandle('maximize');
        $atType = AttributeType::getByHandle('select');

        if(!$maximizeAttribute || !intval($maximizeAttribute->getAttributeKeyID())){

            $maximizeAttribute = CollectionAttributeKey::add($atType, 
                array('akHandle' => 'maximize', 
                'akName' => t('Maximize (Dashboard)'), 
                'akIsSearchable' => true, 
                'akIsSearchableIndexed' => false,
                'akSelectAllowMultipleValues' => false,
                'akSelectAllowOtherValues' => false,
                'akSelectOptionDisplayOrder' => 'alpha_desc'
            ),$pkg);

        }

        // Select options to add -- yes (activated for page), no (specifically NOT activated for page).
        $maximizeAttrOpts = array('Yes','No');

        foreach($maximizeAttrOpts as $maximizeAttrOpt){
            // Check for attribute option - if doesn't exist, create it!
            if(!SelectAttributeTypeOption::getByValue($maximizeAttrOpt,$maximizeAttribute)){
                $maxAttr = SelectAttributeTypeOption::add( $maximizeAttribute, $maximizeAttrOpt, 0);
            }
        }

        // Finally, add new attribute to new set.
        $maxAttrInSet = CollectionAttributeKey::getByHandle('maximize')->setAttributeSet($attrSet);

    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.