add on to install other addons

Permalink 1 user found helpful
Hey all.

I've never been a big fan of PHP but I just want to say again how much I love this CMS compared to every other CMS i've seen in PHP, Ruby or asp.net. its easier to work with and program against than anything else i've used. Kudos to the creators and community behind Concrete5.

With that out of the way, i just wanted to ask a quick question. Is there a way to install add-ons and themes programmatically? When we get a new developer working on an existing Concrete project, they often will have to install a bunch of addons and the theme to get up and running. Some of our add-ons we build for clients have dependencies on others. So is there a way we can build a "site-wide" add-on that will install various third party addons, and our theme in one shot?

Thanks again,
Craig

fregas
 
JohntheFish replied on at Permalink Reply
JohntheFish
There has been talk from Franz and Andrew in Totally Random about being able to set up a custom install package with all your usual addons and changes ready to go. Not sure if it is planned for 5.5 or the next revamp of Concrete5.org
fregas replied on at Permalink Best Answer Reply
fregas
I figured one way of doing it. Yay for open source code.

I have one package that in its install method, i do this:

public function install() {
      Loader::package("artist")->install();
      Loader::package("advertisement")->install();
      Loader::package("designer_content")->install();
      Loader::package("jacks_extended_search")->install();
      parent::install();
  }


That installs any other 3rd party or custom packages we have made.
fregas replied on at Permalink Reply
fregas
In the meantime, or for people on older versions, this seemed to work:

<?php
defined('C5_EXECUTE') or die(_("Access Denied."));
Loader::model('attribute/categories/collection');
Loader::model('collection_types');
Loader::model('single_page');
class MySuperPackagePackage extends Package {
  protected $pkgHandle = 'superPackage';
  protected $appVersionRequired = '5.4.0.5';
  protected $pkgVersion = '1.0.0';
   protected $packagesToInstall = Array("artist","advertisement","designer_content","jacks_extended_search");
  public function getPackageDescription() {
    return t('Add everything needed for Your site.');
  }
  public function getPackageName(){
    return t('My Super Package');


This code creates one master package to install or uninstall other packages as dependencies. Note that when uninstalling or checking for the existence of a package, you have to use Package::getByHandle(), but when installing fresh you have to use Loader:package(). You cannot use loader to load a package and check to see if its installed or not, for some weird reason.
Mnkras replied on at Permalink Reply
Mnkras
its in 5.5
jshannon replied on at Permalink Reply
jshannon
Really? Can you provide more details? I didn't see it in the Package class.