Adding an Additional Block to a Marketplace Package
PermalinkI found this, but it's not the solution I am looking for.
http://www.concrete5.org/community/forums/customizing_c5/extending-...

If you add an "upgrade" function to the package controller, put the block installation code in there, then increment the package version number -- now you can go to the dashboard and "upgrade" the package. This is what the code looks like:
public function upgrade() { parent::upgrade(); BlockType::installBlockTypeFromPackage('your_block_handle', $this); }
(note that I'm not sure about passing "$this" to the installBlockTypeFromPackage function -- seems like it should work but maybe not, in which case you'd have to do "$pkg = Package::getByHandle('the_package_handle')")
BUT if the package is upgraded via the marketplace, you'll get all out of whack because you changed the version number, etc.
For all of my packages, I do the following:
public function install() { $pkg = parent::install(); //Both install and Upgrade pass off to this $this->installComponents($pkg); }
public function upgrade() { parent::upgrade(); //Both install and Upgrade pass off to this $pkg = Package::getByHandle($this->$pkgHandle); $this->installComponents($pkg); }
//This actually lists all components, which are responsible for ensuring they're installed. public function installComponents($pkg) { /* From here, you check to see if each component has been added, and if not, install. For example, I have a custom attribute type called range. */ $rt = AttributeType::getByHandle('range'); if(!$rt->atID) { //Add the new Type $rt = AttributeType::add('range', t('Range'), $pkg); //Associate our type with collections $cakc = AttributeKeyCategory::getByHandle('collection'); $cakc->associateAttributeKeyType($rt); } }
One note, though: upgrade() gets run any time your version number in the package is greater than the one that you had installed. So you want to build the upgrade() function in such a way that it checks to see whether your components already exist, before trying to install them.