JustPaste.it

Concrete5 tips:

Installation:

• before linking the installer to the database, make sure the files directory and all inclusive content is marked "755"… that means everyone should be able to read and write it, but only the server can execute it (I think, important thing to remember is just make it 755 through FTP or SSH).

Themes:

1. Create a new directory to house your theme and name it whatever you want (ie. MyTheme)

2. Create a 120x90 png thumbnail for your theme and place it in the directory. This will be used by the Control Panel.

3. Add a description.txt file to your directory with only 2 lines:

line 1: name of theme (ie. MyTheme)

line 2: short description (ie. "a theme I made for Halloween")

4. index file becomes "default.php"

5. put your new theme in the Themes directory in the Concrete5 folder. This is where C5 will look for it when you add and activate it through the control panel.

Snippets:

Concrete5 uses some standard little snippets to enable us ultra-fast web development. The main things to remember are that there are not too many things to remember (or worry about):

NOTE: if the php shorthand <? …. ?> doesn't seem to be working (ie. you can't get the damn thing to work), try using the full php tags instead: <?php … ?> (just add "php" after the first "?").

1. getThemePath = this is used for relative theme paths.

Snippet:

<?=$this->getThemePath()?>

Original linked style sheet:

<link href='' rel="nofollow" type="text/css" />


With Snippet added:

<link href='' rel="nofollow" type="text/css" />


2. Title replacement = Concrete5 uses a little snippet of php to keep track of things rather than the <title></title> tags in your normal html header.

• delete <title></title> tags from your header

• replace with the following snippet:

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

3. Editable Areas = any are you want to add which allows the user to add images, text, video, etc.

<?php $a = new Area('Content Name'); $a->display($c); ?>

NOTE: You can call your content areas almost anything you want, but Concrete5 has reserved a few names that the system uses for basic functionality. Those names are:

Header Nav - This area holds the header autonavigation block. This is typically the "top level" pages on a site.

Header - This area holds the header image.

Main - This is the template's main content area.

Sidebar - This area is present if the template contains a sidebar.


4. Navigation = like an editable area, but this is one of the reserved names of Concrete5 (see 3 above).

Instead of an unordered list, just add this where your navigation would normally go:

<?php $a = new Area('Header Nav'); $a->display($c); ?>

(Start out with a <ul> styled list as per usual with CSS and when it looks good, simply replace the <ul> with the above php snippet)

NOTE: If you are adding a secondary page custom template Page Type, you will need to add a different sort of Editable Area here, such as new Area('put Auto Nav here dude'). Then, create a new Page Type (in Pages and Themes > Page Types in the Concrete 5 Control Panel). Match the Page Type Handle to the secondary page name template (ie. if template is called "secondarypage.php" the Handle should be called "secondarypage" — do NOT use underscores in either the php file name or the Handle of the Page Type!). Once your Page Type is created, click the Default button next to the new Page Type; this will bring up an editable preview of the template. Click "Edit" to go into Edit mode and then click where it says "Add to put Auto Nav here dude" and add an Auto-Nav block. The navigation will appear. CLICK THIS NAVIGATION AREA AGAIN and scroll to the bottom option "set up Child Pages" -- here, you will be able to check on every page that should use this menu. If they are not clicked, no menu will appear.


5. Selected/Current class for Navigation = Concrete5 uses the class "nav-selected" for its internal processing, so use this class on your stylesheets to specify what the selected page (current page) should look like (ie. in the menu, this class will highlight the page you are currently on).

For example:

#topNavigation ul li a:link { background-color: #ffffff; color: #ff0000; }

#topNavigation ul li a.nav-selected { background-color: #ff0000; color: #000000; }


6. Clear Concrete 5's cache for testing = If you are just playing with typography.css, you might be confused by the stylesheet being cached.

There is a workaround: open ‘concrete/blocks/content/editor_config.php’ and find the following line (usually around Line 19):

content_css : "<?php echo $theme->getThemeEditorCSS(); ?>",


and change it to:

content_css : "<?php echo $theme->getThemeEditorCSS() . "?" . time(); ?>",


This will add timestamp to the stylesheet URL every time, so it won’t be cached. Don’t forget to remove this workaround once you are ready.


7. EDITABLE SCRAPBOOK BLOCKS = let's say you have a section of footer links which you want attached to every single page and you want to be able to edit this section just once and have the changes appear on every page

What you can do, is insert this code where you want the links to go:

<?

$block = Block::getByName('Footer_Links');

if( $block && $block->bID ) $block->display();

?>


Then in your scrapbook make a content block, add the links, save hit rename and name it Footer_Links to match the Editable Area name.


Thats it :)


8. Croppable image - use the croppable_image block in CONCRETE5 folder (in FTP/WWW folder on Harddrive)


Basically, I think you can just add the block through your admin panel and start using it when you Add Content to an Editable Area.

 

… But, here is the advice from the programmer, anyway (I've read it and it doesn't help much. I think he was answering one guy's specific question) ...


I've used the same logic for other blocks I've made to allow cropping/positioning of a thumbnail.


The positioning relies on a human making a judgment call about which part of the image to show. It can't happen automatically.


Just dive into the code and see how it works.

The code you want to swipe is in the controller, in the method.

<?php

$p = max(0, min($this->cropAlignNum, 100)) * .01;

$margin = $goWide ? "" . (($w - $nw) * $p) : "" . (($h - $nh) * $p);

$margin .= "px;";

?>


Of course you'll need to modify to integrate it into your own code, but that should get you started.


Good luck!



9. Search Bar = The search bar has causes a lot of people some problems. So, here is the solution for Concrete 5.3.3.1 (at least)… this is the definitive solution to the indexing problem where you have created additional blocks using non-standard names. Normally, the Search only searches through 'Main' and 'Main Content' editable areas.


NOTE: the indexed_search and database_indexed_search referenced below are located in the concrete/libraries folder. Copy these into the root directory libraries so that it will override the default Concrete settings without messing up the Concrete directory (this is the same way you're always supposed to make changes to core functions).


1) Add in the index_search.php the line:

$is->addSearchableArea('Nate Content');

*in this case, 'Nate Content' is the name of new Editable Area we want to search


2) uploaded index_search.php in his original path and/or also in the override path

(garbled English, but I THINK this just means to either override the original file in the 'concrete' directory or duplicate it to the root directory as per usual, which overrides the default 'concrete' settings, so that you don't affect anything inside the 'concrete' folder in case later you upgrade to a newer version of Concrete5 [you can't alter the concrete directory if you want to upgrade])


3) Create a search page (search RESULTS page?) with a search block configured to search 'everywhere'


4) Add your content's area name in the database_indexed_search.php and indexed_search.php:


from this:

private $searchableAreaNames = array('Main Content', 'Main');


to this:

private $searchableAreaNames = array('Main Content', 'Main', 'Nate Content');

NOTE: 'Nate Content' is our additional block using a non-standard name.


5) Run the indexing job


6) Search should now work!