Saturday 27 October 2012

How to use FCKEditor in PHP

How to use FCKEditor in PHP

To use fckeditor in your webpage. Download it from given address. Include the fckeditor.php file in your webpage where you want to include fckeditor interface. and simply type the given code in the form.

When you submit the form the data would be stored in "fieldname" variable in this given code. You can customize the toolbars by editing fckeditor/fckconfig.js file

Download fckeditor from http://sourceforge.net/projects/fckeditor/files/FCKeditor/2.6.6/FCKeditor_2.6.6.zip/download

 <form method="post" name="ck">
 
 <?php
 BasePath = '/website/pathtofckeditor/';
 $FCKeditor->Value = 'default value';
 $FCKeditor->ToolbarSet = "MyToolbar";
 $FCKeditor->Width = '600px';
 $FCKeditor->Height = '200px';
 $FCKeditor->Create();
 ?>
 
 <input type="submit" name="submit" value="Submit" />
 </form>

Your value will be stored in 'fieldname' variable

URL Rewriting using .htaccess File

URL Rewriting using .htaccess File

Now, Its time to clean up our url. It is very important to have keywords in the url so that search engines can tackle them easily. Further Rewriting urls makes it more readable and it looks very clean.

We can rewrite our urls using .htaccess file. So let us start with

What is .htaccess file? 

It is a common file used by several web servers to control configuration for a directory. Also known as hypertextaccess. It is an extremely sensitive file.

A missing semi colon, incorrect letter or an extra backslash can mess everything up. So, be careful while working with this file. 

To achieve this we have to follow these steps :
  
1. Create a .htaccess file. Save this file in root directory. 
2. Enable the RewriteEngine with this code

        RewriteEngine on
  
3. Now define RewriteRule for the configuration

       RewriteRule ^product-([^/]+)\.html$ product.php?category=$1 

Syntax : RewriteRule INPUTURL OUTPUTURL [FLAGS]



 RewriteEngine on
 RewriteRule ^product-([^/]+).\html$ product.php?category=$1

Above code will result following url -

Original Url    : http://example.com/product.php?category=car
After Rewriting : http://example.com/product-car.html

We can also make our urls look like directories as follows.
  


 RewriteEngine on
 RewriteRule ^product/([^/]+).\html$ product.php?category=$1

Wait... One thing to note : Always use absolute paths for your links while dealing with directory type url rewriting.