Concrete5, File Manager, and Advanced File Permissions

I turned on Advanced Permissions in concrete5 and for a certain user group I got the error message:


Unable to access the file manager.

I tried to fix this by going to the Dashboard > Site Map > Turn on system pages > Dashboard > File Manager and giving permission to my group, but this did not work.

Instead, I had to go to:


Dashboard > System and Settings > Permissions and Access > File Mananger Permissions.
Press the "Add Group" button.
Add your user group.

Concrete5: Prefilling form fields with User Information

Registration: setting up Custom User Attributes

You can add your own custom attributes (for example, name and address) to a user.

First you have to turn on Public Registration (it’s off by default)

Dashboard > System and Settings > Login and Registration > Public Registration

Under “Allow Visitors to Signup as Members” select “On – email validation” (You can choose the other options but this one has been recommend to me, so this is the one I chose).

Then

Dashboard > Members > Attributes

Select or create new attributes and then check “Show on Registration Form“.

Checking this box tells Concrete5 to put this on the registration form. Specifically, in the file:

concrete/controllers/register.php

- under the methond named do_register():

$aks = UserAttributeKey::getRegistrationList();

getRegistrationList() gets all of the attributes which have “Show on Registration Form” checked. If the user filled out that field, then it gets added as a User Attribute.

There are a few posts on how to make a custom registration page so I won’t go into detail about that.

The Form Part

The simplest thing to do is create a single page that will hold your form, then use a bit of Javascript and PHP to “pre-fill” the fields with your User Attributes.

Under the controllers folder (your controllers folder, not the concrete/controllers folder) create a file called sample.php.This is your controller file.

Under the single_pages folder create a file called sample.php. This is your view file.

Then go to the Dashboard > Pages and Themes > Single Pages and create a file called sample.

 

Single pages usually default to view.php, and any content you place in say, single_pages/sample.php will show up where you place:

<?php
print $innerContent;
?>

This bit of code goes into your view.php file (in your theme folder) where you want to place the content from your view (in your single_pages folder…in this case, the file called sample.php which is in the single_pages folder).

Alternately, you can create a template with the same name as the controller and view (in this case, sample.php) drop that file into your theme folder, and that will work too (instead of using view.php). This gives you the chance to customize the look and feel a bit more.

The Form Block

Go to Dashboard > Sitemap and find your page (sample).

Go to view the page and add a form block.

Add some questions to the block and then click “Add”. Once you are done, view the HTML source of the form.

Your inputs will look like:

<input type="text" name="QuestionNumber" value="">

Where I wrote “QuestionNumber” it’s usually a number like “Question24″ or “Question8″. Write these down for the inputs you want to pre-fill.

The Controller

The View

Remember, “special thing” gets passed to the view from the controller by:
$this->set('special_thing', $special_thing);

To see the result

To see the result, if you have permalinks turned on, you can go to sample/form/ to see how it works. If it’s not working, view your source to see if the javascript is getting the values from your controller file.

Pros
Easier than trying to override the form block.

Cons:
Uses Javascript. However, since this only pre-fills the form out for the user, it doesn’t actually prevent the user from using the form (they just have to type in more information without javacript turned on).

Concrete 5: Themes, javascript and css

The following line will give you the path to your theme:

<?php $this->getThemePath(); ?>

And this line will give you the link to your stylesheet (in this case, “typography.css”):

<?php $this->getStyleSheet('typography.css'); ?>

Linking to javascript, images or other files inside of your theme folder is as simple as using echo:

<script type="text/javascript" src="<?php echo $this->getThemePath(); ?>js/jquery.min.js"></script> 

Keep in mind that concrete5 controls the following when you write:

<?php Loader::element('header_required'); ?>

Elements controlled by concrete5:

- favicon

- apple icon

- the title tag and it’s content

- jQuery

 

 

Concrete 5 Setup: a checklist

Below is a work-in-progress checklist of things I do when setting up a Concrete5 site.

Upload a zip file and then SSH to unzip

The unzipped files for Concrete5 clock in at around 31MB which is a super-big upload, so it’s easier to just upload the zip file and SSH to the site to unzip it:

unzip concrete-5-zip-filename-here.zip

Enable Pretty URLs

Dashboard > System and Settings > SEO And Statistics > Enable Pretty URLS

Remove the Concrete5 background images

The Dashboard has background images which are pulled from the Concrete5 site. I personally don’t mind how these images look, however, if you are working locally off your computer it can be a bit of a pain if your internet access goes down (because Concrete5 will keep trying to get the images from the Concrete5 site).

Dashboard > System and Settings > Interface Preferences

Then:

Background image > set to none.

I like to disable the Quick Navigation Bar because I find the way it appears when I hover over the Navigation bar a bit hard to manage.

Set Permissions to Advanced

Config > site.php

<?php define('PERMISSIONS_MODEL', 'advanced'); ?>

So far, to me it seems easiest to set Permissions by “Page Type Defaults”. Then, under each Page Type Default, I set it “Manually”. There’s probably a better way to this however.

Set the config file to 644

The site.php file contains your database information, so to make it more secure set the file to 644 (usually it’s set to this after installation, so this is more of a check).

Turn off Design mode for selected users

Go to Config > then select or create a file called site_process.php.

Say you have a group called, well, “Awful Designers” that you would like to not have Design mode:

<?php
$user = new User();
$group = Group::getByName('Awful Designers');
if($user->inGroup($group)) {
define('ENABLE_CUSTOM_DESIGN', false);
}
?>

Turn on Maintenance Mode until the site is live

This hides everything except for the front page unless someone is a user and logged into the site.

Dashboard > System and Settings > Permissions and Access > Maintenance Mode

Note: I have had issues with maintenance mode. For example, I can’t seem to add custom attributes to a page when a site is in maintenance mode. If you are having problems like this, it’s probably because maintenance mode is on.

Turn off Caching until the site is live

Dashboard > System and Settings > Cache and Speed settings > Basic Cache > Off

When you are developing your site, you sometimes won’t see your changes due to the Basic Cache being on. Turning this off during development will help you with this issue.

Turn off “Checking for updates”

Add the following to your config > site.php file:

define('ENABLE_NEWSFLOW_OVERLAY', false);
define('ENABLE_APP_NEWS', false);
define('WHITE_LABEL_DASHBOARD_BACKGROUND_FEED', false);

This turns off “checking for updates” and also any news items (the news that pops up when you log in). Even if you are working from a local server, Concrete5 will (if you don’t add this) keep checking the concrete5.org site for news and updates, which can be a bit of a hassle.

For further reference, refer to the white labelling support.

Get some good addons

Designer Content.  While it’s worthwhile to learn to create your own block, this addon keeps a lot of the great UI that’s built into concrete5 (for example, the image cropping tool and the link creation tool is built in).

Manual Nav. The Auto-nav block that comes with concrete5 is great but I find this one is actually a bit easier to use (which I am guessing means clients will find it easier to use too. Which means they will call you less).

 

 

Concrete5: Magic Method in the Page List

Concrete5 has a magic method in the PageList Class that allows you to “grab” a list of pages by a custom page attribute.

For example, if you have custom (Boolean) attribute called “event_section”:

 

And that custom attribute is added to any page as “true” (by checking the checkbox):

 

You can, by using this magic method, grab all pages that have this custom attribute.

In this example, the attribute is called “event_section” so the magic method will be named:

filterByEventSection

Remove the underscore, and capitalize the words divided by the underscore (i.e. “EventSection”).

$eventSectionList = new PageList();
$eventSectionList->filterByEventSection(1);

This now gives you a variable ($eventSectionList) that is a list of all pages with the custom attribute “event_section” checked.

To “get” all the sections, use the <strong>get()</strong> method:

$tmpSections = $eventSectionList->get();