overriding single pages

Permalink
I'm trying to override pages as in this how-to by 5fly:

http://www.concrete5.org/documentation/how-tos/developers/overridin...

I'm not understanding how to incorporate this with my controller install and uninstall functions. I've played around with it and can't seem to get it to work!? Can anybody give me some pointers? Thanks!

enlil
 
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
If you have any overrides, you need to remove them manually if you are uninstalling a package. I don't thing there's any way to automatically delete the overrides. But surely you can do some custom coding to trace any overrides and delete them upon uninstall.

Rony
enlil replied on at Permalink Reply
enlil
In the how to it says:

You need to be sure that in your uninstall method you set the pkgID back to 0 to reassociate the pages with core.

I assume what I need to do is change:

array($pkg->pkgID, $cID));

to
array(0, $cID));

in the uninstall method, but I'm not sure I'm even implementing the code properly in controller.php :| Here is what I have, from the install line down...

public function install()
   {
      $pkg = parent::install();
      // install block
      // BlockType::installBlockTypeFromPackage('enlil_', $pkg);
      PageTheme::add('enlil_transparency', $pkg);
   }
   private function overrideSinglePagePackage($pkg){
           $db = Loader::db();
      $p = Page::getByPath('/page_not_found');
             $cID = $p->getCollectionID();
           $db->execute('update Pages set pkgID = ? where cID = ?', array($pkg->pkgID, $cID));
           $p = Page::getByPath('/page_forbidden');
           $cID = $p->getCollectionID();
           $db->execute('update Pages set pkgID = ? where cID = ?', array($pkg->pkgID, $cID));
JohntheFish replied on at Permalink Reply
JohntheFish
I have not looked into the details, but I would guess you need to call resetoverrideSinglePagePackage() from the uninstall method.
enlil replied on at Permalink Reply
enlil
That's where my issue arises. I'm not sure how to do this correctly. Ive tried unsuccessfully numerous times :l

Any help with this would be appreciated!
JohntheFish replied on at Permalink Reply
JohntheFish
You could have a sawing the branch off a tree problem (when you are sitting on the branch).

I have not tried it, but my first guess would be:
public function uninstall()
   {
      $this->resetoverrideSinglePagePackage($this);
      parent::uninstall();
   }


That way, the package still exists when you try to get its id within resetoverrideSinglePagePackage(). If you do it the other way round, the package will be gone before you can get its ID.