How do you automatically install multiple page types in controller.php?

Permalink
Hello,

I have a theme and would like to install all the page types automatically. I have code to just install one, but apparently I have and error when trying to install more than one. Can someone give me example code?

Any help is MUCH appreciated.

havedampton
 
jasteele12 replied on at Permalink Reply
jasteele12
Hi Dave,

You don't say what kind of error message you are getting, but maybe you are looking for something like this:

<?php /* your_package/controller.php */
  public function install() {
    $pkg = parent::install();
    Loader::model('collection_types');
    /* ... */
      // create page types (List, Item)
    $pt = CollectionType::getByHandle('list');
    if(!$pt || !intval($pt->getCollectionTypeID())) {
      $pt = CollectionType::add(array('ctHandle'=>'list', 'ctName'=>t('List')), $pkg);
    }
    $pt = CollectionType::getByHandle('item');
    if(!$pt || !intval($pt->getCollectionTypeID())) {
      $pt = CollectionType::add(array('ctHandle'=>'item', 'ctName'=>t('Item')), $pkg);
    }
  }


Congrats on your marketplace theme :)

John