Single_Page Included In Package Not Working

Permalink
Hi,

I am trying to create a very simple package with one single page. The directory structure is shown below. Company Model has not been used in company controller. My code for displaying company single_page is very simple.. just a text. The package installs successfully but single page text is not being displayed.

If i put company single page in my webroot(/var/www/html/xxxxxxxx/single_pages) directory. Voila it works.

Can you please help me in tracing what i am doing wrong because of which single page content is not working within the package.

.
|-- controller.php
|-- controllers
| `-- company.php
|-- db.xml
|-- models
| `-- company.php
`-- single_pages
`-- company.php

Company - Single page
<?php defined('C5_EXECUTE') or die(_("Access Denied.")); ?>
   check if this is working?
  <?php echo $tempVar; ?>

 
bbeng89 replied on at Permalink Reply
bbeng89
Are you installing the single page when you install the package? The code I use for this (taken from the c5 boilerplate addon) is:

public function install($post = array()){
   $pkg = parent::install();
   $cID = Page::getByPath('/path/to/company')->getCollectionID();
   if(intval($cID) > 0 && $cID !== 1){
      // the single page already exists, so we want
      // to update it to use our package elements
      Loader::db()->execute('update Pages set pkgID = ? where cID = ?', array($pkg->pkgID, $cID));
   }
   else{
      $p = SinglePage::add('/path/to/company', $pkg);
      if(is_object($p) && !$p->isError()){
         $p->update(array('cName' => t('Company')));
      }
   }
}


This is the install() method for your package controller (so the one that lives at /packages/your_package/controller.php).

If you don't want to uninstall and reinstall the package you can also put this code in the upgrade() function, but you'll have to maek sure you increase your package version number ($pkgVersion).

Hope that helps!
geekashu replied on at Permalink Reply
"bbeng89" Thanku for the help.

Don't know what the problem was... i renamed my package and installed it again package started to work normal.

I was not able to reproduce this on other fresh install.