Archive for the ‘PHP’ Category

Controlling Joomla! templates depending on menu you use

Thursday, August 26th, 2010 by Jonathan Shroyer

We have been working on building a multi-school Joomla! website and there have been many hurdles to overcome since Joomla! isn’t a multi-site CMS. After searching for anything that’s common across each school, I realized the menu for each school could be used as a common denominator. If I could set a variable depending on which menu is loaded on the page then I can do just about anything I want, such as change the logo, set a unique CSS class, etc. After meeting with our developers we figured out how to do this and I’ll share it with all of you in case you ever need to do the same.
Read the rest of this entry »

The if() Control Structure

Friday, August 20th, 2010 by Bernard Robbins

if() gives you a choice between outcomes you choose yourself. This gives you the most flexibility out of your projects.

Out of all the control structures, if() is probably one of the most used and has the most flexible ways of being written. Readability should be taken into account when you decide which way to write it. Using braces is the wisest since it doesn’t leave any room for error in what the author meant to include in the statement. if() statements may be written inside functions / methods, inside and outside most other control structures, procedural PHP, and HTML files.

Read the rest of this entry »

How to use countModules in any Joomla! file

Friday, August 6th, 2010 by Jonathan Shroyer

One of the core parts of creating Joomla! templates is using $this->countModules to show or hide code depending on if a module is in a particular position on the page. It is very powerful and it makes your templates very dynamic according to what is happening on the page. So what happens if you need to do this outside of the template index.php file? Save yourself a huge headache and use the following code in any file to check for a module position:

jimport( 'joomla.application.module.helper' );
if(count(JModuleHelper::getModules('left'))) {
	put your code here
}

A very powerful addition to you Joomla! PHP library!

Debugging with Krumo

Thursday, July 29th, 2010 by Bernard Robbins

Some websites do not require advanced debugging with an IDE. If you just want to know the value of a variable without having to step through a site, Krumo may be for you.

The easiest way I have found to add the Krumo library is to use the auto_prepend_file for php. The auto_prepend_file declaration can be inserted into either the php.ini (for your entire web server), the httpd.conf file if you want it for just one site, or in your .htaccess file for a particular sub-directory. This will allow you to prepend a php script before any of your scripts run.

Create a new file on your web server called prepend.php.

include_once('krumo/class.krumo.php');

For php.ini, use:

auto_prepend_file = “auto_prepend.php"

For .htaccess or httpd.conf, use:

php_value auto_prepend_file auto_prepend.php

Resources:

http://krumo.sourceforge.net/

http://php.net/

Cutting down on lines of code with array_walk()

Monday, July 19th, 2010 by Adam Docherty

Hello there!

Today I am going to be talking about the array_walk php function which can help you cut down on lines of code and organize your code better.

An easy way to think of array_walk() is think of it as an automatic way to loop threw arrays of data. From time to time in your coding duties there are likely to be occasions when you find your self writing these kind of loops over and over again: Read the rest of this entry »

Forcing IE7 display in IE8 (updated)

Wednesday, June 10th, 2009 by Jonathan Shroyer

I have been developing for IE8 since it was first released. Although they say it’s a final build, it’s actually in a late beta stage. There are several key CSS commands that haven’t been completed yet (such as :first-letter) and some calculations that still aren’t right in the browser. This is why they built the compatibility mode into it. This creates a major issue for web developers because any conditional statements for IE8 that are put in will break the page once it is fixed. I have thought about every possible fix and the only reasonable solution that I’ve found is… kill it!

Read the rest of this entry »

CMS EXPO – Coming up!

Tuesday, April 21st, 2009 by Rafael Corral

cmsexpochicago
Read the rest of this entry »

Handling Joomla! dates

Thursday, January 29th, 2009 by Rafael Corral

For the longest time, I’ve had troubles parsing the Joomla! date. It is normally found in this format: “Y-m-d H:i:s” which translates to: year-month-day hour:minute:second  or  2009-01-29 22:05:15
Many times before I have parsed this date to change to a format that is more user friendly, but it had never been a one liner.
Read the rest of this entry »

Easy IE Conditional CSS with No Hacks!

Thursday, January 15th, 2009 by Jonathan Shroyer

Any serious CSS person has hacked their way through more ‘Internet Exploder’ issues than they care to talk about. Even if there are only a few small issues to fix in an area, it can be difficult to track them through multiple style sheets (ie. conditional sheet for IE6 & 7). Hacks are just bad practice, so what can you do? There is a better way! I came up with a neat little piece of code that has greatly simplified my life when dealing with cross-browser compatibility.

Read the rest of this entry »

A great way to comment your code!

Thursday, December 4th, 2008 by Rafael Corral

Here is something useful that I created.

If I develop a site and need to output data for debugging, I will have to constantly print arrays.
At some point during coding, I’ll have to comment some code out with the good ‘ol forward slashes ‘//

So I came up with this: Read the rest of this entry »