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!
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!
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:
to
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...
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));
Viewing 15 lines of 97 lines. View entire code block.
I have not looked into the details, but I would guess you need to call resetoverrideSinglePagePackage() from the uninstall method.
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!
Any help with this would be appreciated!
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:
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.
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.
Rony