Reset CSS

Filed Under (CSS) by khawaib on 16-12-2009

Tagged Under : , , ,

CSS Reset

/* v1.0 | 20080212 */

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	font-size: 100%;
	vertical-align: baseline;
	background: transparent;
}
body {
	line-height: 1;
}
ol, ul {
	list-style: none;
}
blockquote, q {
	quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
	content: '';
	content: none;
}

/* remember to define focus styles! */
:focus {
	outline: 0;
}

/* remember to highlight inserts somehow! */
ins {
	text-decoration: none;
}
del {
	text-decoration: line-through;
}

/* tables still need 'cellspacing="0"' in the markup */
table {
	border-collapse: collapse;
	border-spacing: 0;
}

PHP memory limit on Joomla websites

Filed Under (Joomla! 1.5, PHP) by khawaib on 14-12-2009

Tagged Under : , , , , , , , , ,

Some servers have limit on memory for PHP which leads to errors when you start adding new extensions. Memory limit is set in PHP ini file.

Solution 1:

PHP ini file can be located at different locations, easiest way to find the location is to run follwoing script on server.

<?php phpinfo(); ?>

Open the file through ftp or any other way easy for you.

Search for memory_limit word in file and increase its value, 64MB should be fine.

Restart Appache

Solution 2:

You can also include following line before PHP closing tag in configuration file located in Joomla root directory to increase memory limit.

ini_set('memory_limit', '32M');

Exlude/Separate SVN folders

Filed Under (SVN) by khawaib on 08-12-2009

Tagged Under : , , , , , ,

Subversion created hidden .svn folders in all the directories to keep track of changes. These folders can become a headache when it comes to copy a project from one directory to another.

These folders can also become a security issue.

There are many ways solve this problem.

1. Use export feature of Eclipse and it will not export any of the .svn folders.

2. Use copy commands on Win or Linux

tar --exclude='.svn' -c -f - /path/to/sourcedir/* | (cd /path/to/destdir ; tar xfp -)
rsync -r --exclude=.svn /home/user/progname/ /home/user/progname.copy

3. Robocopy

4. Ignore files and folders from repository

Hide .svn folders from Appache

Filed Under (SVN) by khawaib on 08-12-2009

Tagged Under : , , ,

Use following directive in our httpd.conf to prevent Apache from descending into .svn folders.

# Disallow browsing of Subversion working copy administrative dirs.
<directorymatch "^/.*/\.svn/">
    Order deny,allow
    Deny from all
</directorymatch>

CSS with PHP using PHP variables

Filed Under (CSS, PHP) by khawaib on 07-12-2009

Tagged Under : , , , , , , , , , , , ,

Recently one of my client asked me to add the functionality for users of their custom Content Management System(CMS) to give them more control over layouts etc. Using CSS in PHP makes it really easy to have styling flexibility.

Following steps are involved to write CSS via PHP.
Create CSS file as a PHP file

Set its content type using the following code

header("Content-type: text/css; charset: UTF-8");

Create PHP variables as you would normally in other PHP code. You can also bring variable data from database etc.

<?php
$myVariable = '#000000';
$myLeftColHeight = '500px';
?>

Outside your PHP tags you can write all of normal CSS code. Where ever you need to write the variable value just echo that variable not PHP way.

#myLeftCol {height:; color:;}

Final Code for stylesheet.php:

header("Content-type: text/css; charset: UTF-8");
$myVariable = '#000000';
$myLeftColHeight = '500px';
?>
#myLeftCol {height:; color:;}

Including SQL queries inside component XML files

Filed Under (Joomla! 1.5) by khawaib on 07-12-2009

Tagged Under : , , , , , , , ,

For install and uninstall process of component queries can be put into a separate SQL file, however if there are not lot of queries then they can also be included in component XML. For example after languages tags in XML file put following:

<install>
<queries>
<query>
CREATE TABLE `#__comp_groups` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(254) NOT NULL default 

Updating a component parameter from code

Filed Under (Joomla! 1.5) by khawaib on 06-12-2009

Tagged Under : , , , , , ,

Function to add/update configuration values for a component in code.

function updateParms($authKey) {
   $db    =& JFactory::getDBO();
   $query = "SELECT `params` FROM `#__modules` WHERE `module` = 'mod_modulename'";
   $db->setQuery($query);
   $parms =  $db->loadResult();
   $moduleParams = explode("\n", $parms);

   foreach ($moduleParams AS $key => $value) {

      $thisValue = explode("=", $value);
      if ($thisValue[0] == 'authkey') {
         $thisValue[1] = $authKey;
      }
      if ($thisValue[0]) {  // ignore empty lines
         $outputArray[] = $thisValue[0] . '=' . $thisValue[1];
      }
   }
   $params = implode("\n",$outputArray);

   $query = "UPDATE `#__modules` SET `params` = '$params' WHERE `module` = 'mod_modulename'";
   $db->setQuery($query);

   if (!$db->query()) {
         return JError::raiseWarning( 500, $db->getError() );
   }
}

Art Board and Crop in Illustrator

Filed Under (Illustrator) by khawaib on 03-12-2009

Tagged Under : , , , , , , , , ,

In your Illustrator print settings there is an option under ‘Setup’ to crop the print to the: Artboard, Artwork Bounding Box (basically everything in the file) or a specified ‘Crop Area’.

If you want to crop everything in your artboard do following:
You can just mask out everything by making a box the size of the artboard and putting it at the top, selecting all and then doing a CMD+7 to crop it.

Joomla parameters

Filed Under (Joomla! 1.5) by khawaib on 02-12-2009

Tagged Under : , , , , , , , , , , , ,

There are 21 different standard parameter types supported in the Joomla Framework for all extension types (templates, components, modules and plugins). This section gives a brief description of each parameter type, in alphabetical order. Full details of each parameter type are given on the following pages.
Standard parameter types
Component parameters

Internet Explorer 6 (IE6) PNG Fix Techniques

Filed Under (CSS) by khawaib on 02-12-2009

Tagged Under : , , , , , , , , , ,

Following are some of the great techniques and scripts to fix IE6 PNG transparency issue.
DD_belatedPNG
Supersleight jQuery Plugin
PNG 8-bit technique (Fireworks)
Clever PNG Optimization Techniques
PNG Optimization Guide: More Clever Techniques

More and more web designers nowadays not fixing the PNG issue for IE6 anymore.