Archive for the ‘General’ Category

How to set Webserver Directory Index via .htaccess

Thursday, August 19th, 2010

What’s a webserver directory index anyway?

When an HTTP client (generally a Web browser) requests a URL that points to a directory structure instead of an actual Web page within the directory, the Web server will generally serve a general page, which is often referred to as a main or “index” page.

Most often index.html or index.php are used by developers, but we can set it to any file we want to with the help of .htaccess

on your .htaccess file write:

DirectoryIndex home.html

Above code is just telling that I want the file home.html be by default index page.

but you can also do this:

DirectoryIndex home.html index.html index.php

Above is telling the server that to use home.html as my default index page and if not use index.html else use index.php and so on…

So that’s it, fairly easy…

:)

Joomla 404s redirect

Thursday, August 5th, 2010

If you want to see the error page in theme design and don’t like redirecting to error page URL or duplicating HTML in the error page template, here is a way to apply your theme template to the error page.

First, put the following code in templates/system/error.php:

Dont forget to put it

    BEFORE THE DOC TYPE!

<?php 
if ($this->error->code == '404') {
    header('Location:www.domain.com/your-custom-error-page.html');
    exit();
} 
?>

Thats it!

How to enable GD library on WAMP5 – simplier than you think…

Saturday, July 17th, 2010

How to enable GD library on Wamp5?

(This I assume you have running wamp5 on your system)

Click Wamp5 icon on lower right hand of your screen (see image)

wamp5

Click PHP settings …

wamp5

Click PHP extensions …

wamp5

If there’s an triangle already showing right across php_gd2 GD is already running and you can now create image on the fly(via PHP), but if no triangle  it is not enabled and to enable it just click and restart your server :)

Thats it. Its really amazing right :)

Youtube embed code to pass w3c HTML validation? yes there’s a solution, see here!

Saturday, July 17th, 2010

For those who scour the net for a simple solution for a problem called “Make my YouTube embed code pass w3c HTML validation“, your in the PERFECT place, because what you’re about to read is not only simple, but the perfect solution!

Very confident me will now show you how its done :)

The usual Youtube embed code(do not pass w3c HTML validation)
NOTE: where ($vid) is your Youtube video ID

<object width="430" height="347">
<param name="movie" value="http://www.youtube.com/v/($vid)&amp;hl=en_US&amp;fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/($vid)&amp;hl=en_US&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="430" height="347"></embed>
</object>

Ok you see, when using this code to display video, it will never pass validation but instead will render validation error such as “there is no attribute allowfullscreen”, “width” among others.

But with the code below, you can perfectly validate your Youtube pages :) see below and test it yourself.

NOTE: ($vid) is = to your Youtube video ID, for example http://www.youtube.com/v/RHzC7YOxkVY&hl=en_US&fs=1 the emphasized letters is your Youtube ID, So now presenting the code…

<object type="application/x-shockwave-flash" width="430" height="347" data="http://www.youtube.com/v/($vid)">
<param name="movie" value="http://www.youtube.com/v/($vid)" /></object>

Oh my, yes its much shorter, and its better!!! :D

How will I know if im on Joomla! home page or in innner page?

Tuesday, May 25th, 2010

As the title suggest, how will I know if I’m on Joomla! home page?

for example:

if('ImOnHomePage'){
  do this...
}else{
  do this instead...
}

A quick answer should be via PHP $_SERVER global variable:

<?php
$uri = $_SERVER['REQUEST_URI'];
if ($uri == "/" || $uri == '/home.html') {
  echo 'Im on home page';
}else{
  echo 'Im not on home page';
}
?>

Please before trying to update or change your templates/TemplateName/index.php file please do make a backup. It can save your life :)