Ckeditor integration in cakephp

Ck-editor is a popular open source editor for web. To plug-in this editor in your cakephp application just follow the steps.

Step-1:

Download ck-editor from www.ckeditor.com/download/

Step-2:

Unzip the file and Keep your files inside webroot /js/ckeditor directory

Step-3:

To load the editor we just need to link up the ckeditor.js file in the view file. Then put a class named “ckedior” in your text area. Thats it to load the editor inside the text area.

<?php
       echo $javascript->link('/ckeditor/ckeditor'); //Link the ckeditor.js file on the page you want to use the editor.
?>
<?php echo $form->textarea('content', array('id'=>'content','class'=>'ckeditor')); ?>

Editing *.ctp file in Eclipse.

Eclipse is a famous editor for the development with php. But to code with cakephp we need to configure this eclipse editor. Because by default eclipse does not hightlight the html or php syntex of cakephp view file.Here are the steps to set up eclipse for highlighting the codes in a .ctp file.

  • Firstly open the  Eclipse workspace.
  • Now go to Preferences from Window menu.
  • From Preference click on the General tab from the list.
  • Now click on Content-Types under General  tab.
  • On the right panel in the Content-Types, expand the Text tab.
  • Select PHP Content-Types .
  • There are all the lists of  files associated with php in below e.g. *.php,*.php3,*.php4
  • Now click on the Add button and type the fie extension e.g. *.ctp in the content type input field.

Now you need to reopen the file  you are working on.

Happy coding :)

Uploading error named “Error creating folder” in Fckeditor

Last few days i was trying to solve a path issue regarding the Fckeditor. I was using the editor with php.It was little bit annoying this time cause it took few hours to find out. The editor was working fine wihtout any problem. For no reason suddenly the editor started showing the error messge while i was tyring to upload an image with the html editor. Most of the time the error seems more or less like below :

  • Error creating folder '/Resources/ImageFile/image' {Can't create 'image' directory}
  • Not getting the UserFilesAbsolutePath.

Well the editor have a configuration file for solving this issue with php.Here we need to be sure for the following three lines of code.

  1. $Config['UseFileType'] = true ;
  2. $Config['UserFilesPath'] = ‘/Resources/ImageFile/’ ;
  3. $Config['UserFilesAbsolutePath'] = ‘D:/PHPWorks/alpha-v2/Resources/ImageFile/’ ;

Remember the file path for UserFilesAbsolutePath usually not given while we download Fckeditor. In few versions of fckeditor it works fine without this path. But to stop the error message if any we should enter an absolute path for the destination directory. In my case my server was a windows server. Thats why i used the absolute path like above.

Last but not least imoprtant issue is the chmod of the destination directory should be set to 777 that means the directory should be writable to upload an image in it.

Magento configuration to change site URL

In magento by deafult the configuration information for site management is kept in database table. The name of the table is ‘core_config_data’. If we analyze the tables we get that magento keeps its data in the following table. So if we want to develop our application in our localhost and then deploy the site in the hosting server we might need to change the path accordingly to run the site from that server.

Here we see that magento keeps its base url as below

(2, ‘websites’, 2, ‘web/unsecure/base_url’, ‘http://192.167.3.7/magento/’)

So here we can change that url easily as we need to. This way we can configure multiple URL for multiple site also. In my case this tricks worked fine with Magento 1.3.1

CREATE TABLE `core_config_data` (
`config_id` int(10) unsigned NOT NULL auto_increment,
`scope` enum(‘default’,'websites’,’stores’,'config’) NOT NULL default ‘default’,
`scope_id` int(11) NOT NULL default ‘0′,
`path` varchar(255) NOT NULL default ‘general’,
`value` text NOT NULL,
PRIMARY KEY  (`config_id`),
UNIQUE KEY `config_scope` (`scope`,`scope_id`,`path`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;


– Dumping data for table `core_config_data`

INSERT INTO `core_config_data` (`config_id`, `scope`, `scope_id`, `path`, `value`) VALUES
(1, ‘default’, 0, ‘catalog/category/root_id’, ‘2′),
(2, ‘websites’, 2, ‘web/unsecure/base_url’, ‘http://192.167.3.7/magento/’),
(3, ‘websites’, 2, ‘web/unsecure/base_link_url’, ‘{{unsecure_base_url}}ucc/’),
(4, ‘websites’, 2, ‘web/secure/base_url’, ‘https://192.167.3.7/magento/’),
(5, ‘websites’, 2, ‘web/secure/base_link_url’, ‘{{secure_base_url}}ucc/’),
(6, ‘websites’, 2, ‘web/default/front’, ‘cms’),
(7, ‘websites’, 2, ‘web/default/cms_home_page’, ‘home’),
(8, ‘websites’, 3, ‘web/unsecure/base_url’, ‘http://192.167.3.7/magento/’),
(9, ‘websites’, 3, ‘web/unsecure/base_link_url’, ‘{{unsecure_base_url}}technocare/’),
(10, ‘websites’, 3, ‘web/secure/base_url’, ‘https://192.167.3.7/magento/’),
(11, ‘websites’, 3, ‘web/secure/base_link_url’, ‘{{secure_base_url}}technocare/’),

Translation of “Agar hum kahen aur wo muskura dein”

Agar Hum Kahen Aur Woh Muskura Den

Artist: Jagjit Singh
Album: Passions – Black Magic


Agar hum kahen aur wo muskura dein
if i be somewhere and she smiles for me.
Hum unke liye zindgaani luta dein
i would give-up my life for her.

Har ik mod par hum gamon ko sazaa dein
on every turn of life i would punish the sorrows.
Chalo zindagi ko mohabbat bana dein
Come on let’s make our life our love.

Agar khud ko bhoole to kuch bhi na bhoole
if i forget myslf, means i forgot nothing.
Ke chaahat mein unkee khuda ko bhula dein
Rather i would forget god in her love.

Kabhi gam kee aandhee jinhen choo na paaye
may d blind sorrow never touch her.
Wafa ke hum wo nashe-man bana dein
make me addicted to goodwill of hers.

Qayaamat ke deewaane kehte hain humse
lovers of beauty tells me to.
Chalo unke chehre se parda hata dein
unveil the curtain from her face.

Saza de silaa de, bana de mitaa de
punish me.. Judge me, make it… Erode it.
Magar wo koi faislaa to sunaa de
but at least give some judgment.

Translated By: TarakNath kar