Add Canonical URL when Creating Page Programmatically
PermalinkLoader::model('collection_types'); $path = "/resources/newpage"; $newPage = Page::getByPath($path); $data = array(); $data['cName'] = $title; $data['cDescription'] = $title. " " .$date; $data['cURL'] = $pageURL; $ct = CollectionType::getByHandle('right_sidebar'); $newPage->add($ct, $data);
I thought it would be $data['cURL'] as shown above. But that doesn't work.
Any suggestions?

i setup a package with a template, blocks and a single page. everything works fine.
now i add the code above to the package controller, but i get an error.
Call to a member function getPackageID() on a non-object in F:\Server\xampp\htdocs\projekte\C5-Developer\concrete\models\page.php on line 1943
here is the code i add to the controller
Loader::model('collection_types'); $path = "/"; $pr = Page::getByPath($path); $data = array('cName'=>'Hallo Welt', 'cDescription'=>'Testet einfach drauf los', 'cHandle'=>'halle-welt'); $ct = CollectionType::getByHandle('right_sidebar'); $pr->add($ct, $data);
did i miss something?
thanks for your help
Also, are you getting this error when you try to install the package, or some other time (like when a page is viewed or edited)?
BlockType::installBlockTypeFromPackage('autonav', $pkg);
The autonav block is already installed as part of the core C5 system -- you cannot have another block with the same name.
Is this just for some custom template files? If so, you don't need to do anything in the install function -- as long as they're in the proper place ( YOURSITE/packages/henrich_parkett_pack/blocks/autonav/templates/ ).
Or did you create another block called "autonav"? If so, you need to rename it.
the autonav is only for the custom template on a fresh installation of C5. I found the problem with the page installation. i forgot to install the page-type i want to use. but now i run into another problem.
i love Concrete5 for this "learning by doing feature" ^^