Cynics Soapbox

Random thoughts...

Concrete 5 - Add Block to page_type

When writing the page_type template it’s possible to embed to areas using the standard area code, $a = new Area('area_name'); $a->display($c); Using the Defaults option on the Dashboard / Page Types screen it’s then possible to add blocks to the area you created. In my case I was installing the page_type as part of a package so I didn’t want to have to ask people using it to add in blocks themselves....

Adding Pages to Concrete5

I recently found myself wanting to add a page in a piece of code and it took me a few attempts to get it working, so here is how I eventually figured it out. You’ll need the parent page and the type of page, though this is actually referred to internally as a CollectionType. <br></br> $ct = CollectionType::getByHandle('full');<br></br> $parent = Page::getByPath('/blah');<br><...

C5 Installing an Attribute Type

If you have an attribute type in a package you need to do a little additional work in the install routine to get it registered fully with the system. <br></br> /* We install the attribute... */<br></br> Loader::model('attribute/type');<br></br> $at = AttributeType::add('country', 'Country', $pkg);<br></br> /* then we associate with collections and users. */<br></br>...

C5 Packages & db.xml

Until I started looking at the code it wasn’t apparent how a package should add tables to the database when being installed in Concrete5. As with much in C5 the answer is simple, but not easily found 🙁 In your package, in the top level directory, create the db.xml file in the same way that you would for a block and it will be automatically found and installed during an install or upgrade. Simples! If you want to have...

Concrete 5 & Its Cache

Yesterday I ran into an odd bug where I couldn’t get a function I defined in a controller to be run. The actions are how you can get various function be called from a controller and they area reasonably straightforward to use – when they work! If you have a controller for /blah and you want /blah/foo to run a function then you simply add a function called foo to the controller. Rather than hardcode the url you use...

Country Attribute Type in C5

For a project I want to be able to add the country to a page. The obvious way to do this seemed to be use an attribute, but ideally with the user choosing from a list. There is already a country list in the standard Address attribute type, but I didn’t want an address, just the country. So, after some hunting around I managed to create a new Country attribute type using the code below. The code is pretty...

Installing Concrete 5.6.0

Yesterday I downloaded the latest installer for Concrete5 and tried to install it. After creating the database and users, entering the information it all looked as though it was going to be a breeze – but the blue progress bar turned red and a back button appeared. There was no visible error message, but the red progress bar didn’t look good 🙁 After removing the tables from the database (all 167 tables had been created) I tried again and got the...

Concrete 5

Recently I’ve been working with Concrete 5 for a small website. I’d never come across it until it was put forward as a solution for this project but as it was open source and had good reviews we’ve been looking at using it in more detail. I’ve been having some trouble trying to figure out how to best integrate some of the data that the site will require, but am slowly making headway. I started off...