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 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.
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.
Remember, “special thing” gets passed to the view from the controller by:
$this->set('special_thing', $special_thing);
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).
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
Below is a work-in-progress checklist of things I do when setting up a Concrete5 site.
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
Dashboard > System and Settings > SEO And Statistics > Enable Pretty URLS
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.
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.
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).
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);
}
?>
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.
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.
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.
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 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();
Often Javascript errors will give you an installation error message.
If you are getting an error along the lines of “please enable Javascript in your browser” and you know that you are running Javascript in your browser, turn on Firebug / Developer Tools and check your console.
For me I had a local install where I put special characters or spaces in my folder name, and once I removed these the Javascript error message went away
If you are getting a “permissions” problem with your following folders
config
files
packages
Open Terminal.
Change to the folder with concrete5. On a Mac often your site is in your Sites folder, so:
cd Sites
cd my-folder-name
Then try:
chmod -R ug+rw config files packages
If you get an error like:
chmod: Unable to change file mode on [fill in the blank]: Operation not permitted.
Try using sudo
sudo chmod -R ug+rw config files packages
On Windows, I believe you can use runas instead of sudo.
runas /user:Administrator cmd
Then check your installation screen in the browser.
If you find you have to make certain folders (for example, config and files) 777 to either run your site or to install concrete5, you have to change your “group” permissions to your web server.
For example, if you switch into your web folder (the folder with “blocks” , “concrete” etc)…for me it’s public_html and type
ls -la
You might see something like:
drwxr-rw-r--@ 6 my-username staff 204 21 date foldername
On a MAC, my-username is your “user”, and “staff” is your group. However, you probably want to make your group your webserver (“_www”) and give read write permissions to your web server for:
config
files
packages
updates
blocks (optional, for addons like "Designer Blocks")
Writing 777 will give write permissions to your web server…and everybody else (i.e. the world). A better way is to set your webserver to be your group by changing into your web folder (the folder that contains “blocks”, “concrete”, “config” and so on)
sudo chown -R your-username:_www .
Then when you type
ls -la
You should see
drwxr-rw-r--@ 6 my-username _www 204 21 date foldername
CHOWN changes the owner. It’s in the format CHOWN user:group, so:
CHOWN my-username:_www
- sets the user to me (my username) and the group to “_www” (the webserver on my MAC).
-R changes the permission of the folder, and also anything inside the folder (including other files and folders). -R stands for recursive.
Then you can set:
sudo chmod -R ug+rwX files packages updates config blocks
The capital “X” gives webserver “execute” access on directories (which it needs) but doesn’t let it execute any of the files in your directories (which you do NOT want…for example if someone uploads a malicious file to that directory, you want to make sure no one is running or executing the file except for you).
Shared hosting is trickier because the settings are different for each hosting service.
For my hosting service, my apache webserver is referenced by “nobody”, so if I had problems with setting something to say, 755 or 644 I could try setting my group to “nobody” so that my webserver has the same permissions as my user (me).
sudo chmod -R 755 config/ files/ packages/
sudo chmod 644 config/site.php
sudo chmod 755 sitemap.xml
Reference:
http://likesalmon.net/little-changes-to-get-concrete5-working/