Jordan Lev Logo Jordan Lev's Concrete5 Tips

How to make things work when building a Concrete5 website.

Hard-Coded Autonav Options

| Comments

It is often useful to “hard-code” the autonav block directly into your templates, so that the user doesn’t have to configure them and you can guarantee that they’ll always appear on every page of the site. Unfortunately, figuring out what the various options are and what they do can be very confusing. Below I’ve documented all of the available options, along with the corresponding explanations from the autonav block edit window.

New in Concrete 5.5.2: Multiple Rich Text Editors on the Same Edit Page

| Comments

The release of Concrete version 5.5.2 finally addresses a long-standing bug that prevented multiple “rich text editor” controls (a.k.a. WYSIWYG editors, a.k.a. TinyMCE) from coexisting on the same page. Prior to this release, the javascript for the rich text editors would interfere with each other (as well as with the image and page link choosers), so that inserting an image into one field would wind up in another field (or sometimes not show up at all).

As of Concrete version 5.5.2, it’s now really simple to include as many rich text editors as you’d like on a single block add/edit page or dashboard page:

1: Include this one time (regardless of how many rich text editors you have) at the top of the file:

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

2: Include these two lines in each place you want a rich text editor:

<?php Loader::element('editor_controls'); ?>
<textarea name="your-field-name" class="ccm-advanced-editor"></textarea>

That’s it – nice and simple! Note that the class="ccm-advanced-editor" is required on the textarea (this is how the TinyMCE javascript knows which text areas to apply itself to).

Here is a sample edit.php file from an imaginary block that has two fields for content:

<?php defined('C5_EXECUTE') or die("Access Denied.");


<div class="ccm-block-field-group">
    <h2>First Example Field</h2>
    <?php Loader::element('editor_controls'); ?>
    <textarea id="field_example_1" name="field_example_1" class="ccm-advanced-editor"><?php echo $field_example_1; ?></textarea>

<div class="ccm-block-field-group">
    <h2>Second Example Field</h2>
    <?php Loader::element('editor_controls'); ?>
    <textarea id="field_example_2" name="field_example_2" class="ccm-advanced-editor"><?php echo $field_example_2; ?></textarea>

I’ve updated Designer Content in the marketplace to version 3.1, which now includes this functionality. It also makes the generated code simpler, which is a major bonus!

Bonus for astute readers: You may be wondering how the “editor_controls” element (the blue Concrete5 bar that sits above the normal TinyMCE controls) knows which text area to attach itself to… Turns out it doesn’t! The Concrete5 bar will insert images, files, and links into the text editor that currently has the focus (or the last one to have the focus if neither of them has the focus currently). Usually this isn’t an issue because people tend to insert images and links when they’re typing into a specific editor field, so the field they’re typing into will by definition already have the focus. But I can see how this might cause occasional confusion… not a huge deal but something to be aware of.

I did see something in the code that looks like it lets you specify an “id” to apply controls to, but I haven’t had the time or motivation to investigate further. If anyone has any ideas about this, please leave them in the comments.

Fixing Func_get_args Bug in Concrete 5.5.2

| Comments

UPDATE: Concrete5.5.2.1 fixes the issue mentioned below – if you’re running Concrete5.5.2, you should just upgrade to to fix this problem (and several other bugs).

A rather nasty bug was introduced in Concrete 5.5.2 that affects many image gallery addons (Simple Image Gallery, Sortable Fancybox Gallery, Deluxe Image Gallery, etc.) as well as the File Manager’s “File Sets” page.

The error looks like this: Fatal error: func_get_args(): Can't be used as a function parameter in [...]/updates/concrete5.5.2/concrete/libraries/item_list.php on line 515 (or it may look like this, if your site started out with 5.5.2 as opposed to being upgraded): Fatal error: func_get_args(): Can't be used as a function parameter in [...]/concrete/libraries/item_list.php on line 515

It appears that this bug will be addressed in the next release of the system, but who knows when that will happen. In the meantime, you can fix this on your site by making a small modification to the file mentioned in the error message (look for SITEROOT/updates/concrete5.5.2/concrete/libraries/item_list.php first, but if that file doesn’t exist then look for SITEROOT/concrete/libraries/item_list.php).

Find this line of code (should be around line #515):

$this->sortByString = implode(', ', func_get_args());

…and replace that 1 line with these 2 lines:

$args = func_get_args();
$this->sortByString = implode(', ', $args);

As soon as you save that file, your image galleries and file manager should immediately start working again.

Minimal Attribute Type Code

| Comments

Creating your own attribute types in Concrete5 can be very confusing because there are a TON of things you can do with them. If you look through the code for the built-in attribute types (in the SITEROOT/concrete/models/attribute/types/ directory), it is hard to figure out what is essential versus what is specific to each attribute type’s custom functionality.

I’ve had to create a few custom attribute types recently, and in the process of doing so I pared down the code to the bare essentials. I’ve posted this sample code on my github repo:

Hope this helps!

How to Build a Slideshow Block (With Flex Slider)

| Comments

Flex Slider (screenshot from
Flex Slider (screenshot from

If you need to build an image gallery or slideshow for a Concrete5 site, I’ve made some boilerplate code available that handles all of the editing and database infrastructure so you can concentrate on implementing the front-end (usually a jquery image gallery or slideshow plugin). The code is available here:

C5 Designer Gallery on GitHub

Read on for details and instructions on how to use it, using the Flex Slider as an example…

File Upload Attribute for User Registration

| Comments

A project I worked on recently required that users upload a file when they register for the site. I thought the built-in “Image/File” attribute type would be able to handle this, but I was wrong. The problem is that it only provides a File Manager selector, not an actual HTML file input tag. Even if I wanted to let the general public see the File Manager (which I don’t), it wouldn’t work because these are unregistered people who don’t have access to the File Manager anyway.

So I created my own attribute type for this, and am sharing it here.

Read on for installation instructions, usage details, and caveats/limitations…

Customizing the Autonav Template

| Comments

The built-in Autonav block is one of the most essential blocks in a Concrete5 site (right up there with Content and Page List). But if you’ve already designed a menu with a certain HTML and CSS structure, it can be very difficult to modify the autonav template to suit your needs because its default template is rather messy.

I don
I don’t think we’re in HTML Kansas anymore

For example, what if you want to change the name of the class that indicates the current page from the default “nav-selected” to the more succinct “active”, or “current” (something that is used frequently in other systems’ dropdown menus)? Or what if you want to add a new class denoting the first or last item in the list? Or what if you want to do something more drastic like change the unordered list structure to a series of divs and spans? I consider myself a decent programmer and even I would be afraid of messing with that code!

But after a year of struggling with the autonav template on dozens of sites, and a healthy dose of assistance from other members of the C5 community, I’ve finally gotten it all figured out and have re-constructed the template so it is cleaner and easier to customize. Behold!

Ahh.... much better
Ahh…. much better

Not only is the markup nice and clean, but this template includes a ton of additional features beyond what the built-in autonav template provides (although it doesn’t break backwards compatibility in any way – you can use this new template unmodified and your site’s markup will not be any different than it was before). Some of the additional features available to you are:

  • Ability to easily set and change class names for a variety of different circumstances (e.g. first and last items, item contains dropdown, unique class for every single item, etc.)
  • Fixes a Concrete5 bug that resulted in all child pages of an excluded page to be included in the menu (the same functionality included in the Autonav Exclude Subpages addon)
  • Recognizes a new custom attribute (exclude_subpages_from_nav) you can add to your site that lets you exclude all of a page’s children without excluding that page itself
  • Lets you set up a custom attribute (nav_item_class) for a custom class name – whatever text is entered into that attribute for a certain page will get outputted into the menu item’s list of classes