Monthly Archives: January 2012

Concrete5: How to exclude a certain page type from your autonav menu

Here is how I exclude specific page types from an autonav menu in Concrete5.

Navigate to concrete/blocks/autonav and open the view.php file.

Scroll down to this line:

foreach($aBlocks as $ni) {
		$_c = $ni->getCollectionObject();
		if (!$_c->getCollectionAttributeValue('exclude_nav')) {

Add this block of code:

$typeHandle = $_c->getCollectionTypeHandle();
			if($typeHandle!="page_type"){

Change “page_type” to the handle of page type that you want to exclude from your autonav menu (for example: blog_post).

Now scroll down and add “}” after this line:

$lastLevel = $thisLevel;
			$i++;

You can also see or download the edited view.php here (this is a text file, so if you want to use it, make sure you save it as a php file!!).

MySQL: Moving columns from one table to another

Here are the steps you can use to move a column from one table to another (within the same database) using MySQL commands.

 

1) Create a new column in the table you are moving your column to. You will want it to make sure the new column is created to hold the same type of data as the column you are moving. Here is a code example:

alter table destinationtable add column destinationcolumn varchar (250) ; 

2) Now, we will copy the contents of the existing column to the new column we just created:

INSERT INTO `destinationtable`( destinationcolumn )
SELECT existingcolumn
FROM `existingtable`

3) You can also add a condition to the statement if you are moving multiple columns and need to make sure that the data is placed correctly:

UPDATE `destinationtable`,`existingtable` SET destinationtable.destinationcolumn=existingtable.existingcolumn
WHERE destinationtable.productid=existingtable.productid

 

 

CSS Tricks: How to make sure an image is always centered inside its div

Here is the code I use to keep an image always centered inside its containing div, regardless of browser width or resizing:

<img src="yourimage.jpg" style="width:100%;margin:0 auto;">

CSS Tricks: How to use a semi-transparent background in a div without affecting the text

Here is the simple way to add a semi-transparent background to a div without affecting the text elements inside the div.

Instead of this code:

background:#555;
opacity:1;
filter:alpha(opacity=100); /* For IE8 and earlier */

Use this:

background-color:rgba(255,0,0,0.5);

If you dont know the rbga value of the hexidecimal color you want to use, you can find it at http://www.color-hex.com/. Just type the hexidecimal value into the box at the top right corner of the page and click “Get color info.”

Take the rgb value  it provides you and put the three numbers into the paranthese in the block of code above. Then simply add the percent of opacity that you want to add to the background (i.e. 0.5 for 50%, 0.8 for 80%, etc.).

Concrete5: How to fix the issue of captcha images not displaying in your web pages

Here is one way I have found to fix an issue in Concrete5 where your captcha images are not showing up.

Navigate to  concrete/helpers/validation/ on your server and open captcha.php.

Find this block of code:

class ValidationCaptchaHelper {

   private $securimage;
	public function __construct() {
		Loader::library("3rdparty/securimage/securimage");
		$this->securimage = new Securimage();
		$this->securimage->ttf_file = DIR_LIBRARIES_3RDPARTY_CORE . '/securimage/elephant.ttf';
	}

And change it to:

class ValidationCaptchaHelper {
   private $securimage;
	public function __construct() {
		Loader::library("3rdparty/securimage/securimage");
		$this->securimage = new Securimage();
		$this->securimage->use_gd_font = true; $this->securimage->gd_font_file = DIR_LIBRARIES_3RDPARTY_CORE.'/securimage/gdfonts/caveman.gdf';
		$this->securimage->ttf_file = DIR_LIBRARIES_3RDPARTY_CORE . '/securimage/elephant.ttf';
	}

The text in red is the text that you are adding to the original block of code.

This worked for me but let me know if it doesn’t work for you.

Concrete5: How to add a unique body class to individual pages

Here is the easiest way I have found to add a unique body class to individual pages in a Concrete5 site.

First, in your dashboard go to “Pages and Themes,”then “Attributes,” and add a custom attribute (text field) called bodyclass.

Next, open your theme’s header.php file and add:

class="<?php echo $c->getCollectionAttributeValue('bodyclass')?>"

to your < body > tag, so it reads like this:

<body class="<?php echo $c->getCollectionAttributeValue('bodyclass')?>">

For any page that you want to apply a custom class to, simply add the Body Class custom attribute and type whatever class name you want into the Body Class Custom Attribute text field. When you save your changes, your opening < body > tag will now look like:

<body class="red">