update name of package and single page names

Permalink
I've got a custom package that I want to change the name of, and also the name of some of single pages that are installed on the dashboard. I don't want to change the handle of the package.

I've worked through the controller and if I do a fresh install of the package it appears as I would like it. I have some existing installations where I don't want to uninstall and reinstall. I want to upgrade. However the key items don't update on an upgrade. I'm assuming I've not got the right info in the upgrade section of the controller.

Any helpful suggestions on the tweaks to the controller code below:

public function install() {
      $this->load_required_models();
      $pkg = parent::install();
      //install blocks
        BlockType::installBlockTypeFromPackage('catastats_list', $pkg);
        $iak = CollectionAttributeKey::getByHandle('icon_dashboard');
      $spa = SinglePage::add('dashboard/catastats', $pkg);
      $spa->update(array('cName' => 'Event Report Manager', 'cDescription'=>'Add Reports.'));
      $spa->setAttribute($iak,'icon-list');
      $spb = SinglePage::add('dashboard/catastats/search', $pkg);
      $spb->setAttribute($iak,'icon-search');
      $spf = SinglePage::add('dashboard/catastats/add_catastats', $pkg);
      $spf->update(array('cName' => 'Add/Edit', 'cDescription'=>'Add/Edit Reports.'));
      $spf->setAttribute($iak,'icon-pencil');
      $spc = SinglePage::add('dashboard/catastats/attributes', $pkg);

 
JohntheFish replied on at Permalink Best Answer Reply
JohntheFish
As you are keeping the package handle, that makes it straight forward because ownership of everything associated with a package is tied to the package handle through the package id.

So all you need is to edit the package name and the single page names or locations.

The install() method only runs on a fresh install of the package. If its an already installed package, you have 2 choices:
a) Write code for renaming and/or moving the single pages into the package controller update() method.
b) Use the dashboard sitemap and just rename and/or move the single pages manually. If its only on 1 or 2 sites, this is the easy option.

Be careful when renaming or moving single pages because there may be links between them or with other pages that are coded into the package.

A new package name as in the getPackageName() method will take effect when the update is run. All you need to do is edit the text and make the update run - simplest by appending .0.0.0.1 to the version.

(If you were on c5.7 or v8 there is a command line utility to force an update or my Package Magichttp://www.concrete5.org/marketplace/addons/package-magic/... , but not on 5.6)
justynpride replied on at Permalink Reply
Hi JohntheFish

That is so helpful. Thank you. I will use option b for the existing packages.



> On 10 Feb 2018, at 20:12, concrete5 Community <discussions@concretecms.com> wrote: