Kurinchi Blogger Scribbles …


Archive for June, 2009

Jun 12
2009

cakePHP: Static page handling tips

Last updated: June 17th, 2009

You can create static pages in cakePHP by adding .ctp files under /app/views/pages folder and can access it using the URI http://sitename/pages/pagename.ctp.

Try creating two files page1.ctp and page2.ctp and add those files under /app/views/pages folder.

page1.ctp

<h1>Page 1</h1>
<p>Static Content for page 1 goes here</p>

page2.ctp

<h1>Page 1</h1>
<p>Static Content for page 1 goes here</p>

(more…)

Jun 11
2009

JQuery: Showing a progress image while processing background task

Last updated: June 11th, 2009

I thought to write a simple example to show a progress bar or a gif image showing a that a task is happening at the background using a jquery function.

i) Include jquery script file in the header section and the following code in the head

<script language="javascript">
$(document).ready(function(){
    $('#progress').hide();
    $("#main a.bgdiv").click(function(){
        $("#progress").show("slow");
        $("body").load($(this).attr('href'));
        return false;
    });
});
</script>

(more…)

Jun 10
2009

Google Chrome “Aw, Snap!” … Something went wrong

Last updated: June 11th, 2009

How to fix Google Chrome Error?

i) Close the chrome browser

ii) From the shortcut on your desktop or from task bar right click “Chrome” and select properties.

iii) For the “Target” option add “–no-sandbox” towards the end.

iv) Now restart chrome and everything should work fine.

REMEMBER: –no-sandbox” is to be used for testing purposes and it is not safe to use chrome with –no-sandbox option as it seems to have security vulnerabilities

Jun 09
2009

cakePHP: Session enabled messages using Session->setFlash

Last updated: June 9th, 2009

There are different ways to flash or publish the messages for a user action. Usability plays a major role in determining how the navigation pattern for a web application takes place.

  • publishing the outcome of user action on the same page
  • designing a single page to flash all success, error, warning, notice level messages
  • designing a separate page for each message that gets published for the user

(more…)

Jun 07
2009

Strange character sequence when parsing XML

Last updated: June 9th, 2009

When XML files are read from RSS feeds or from other sources, it is necessary that they both use the same standard encoding. When there is a conflict, strange characters like ‘, ’ gets shown on the browsers.

In RSS feeds, UTF-8 is the standard encoding scheme that is used and if a browser using ISO-8859-1 tries to read and display the data from the feed then these characters get passed on to the display.

To avoid having this strange characters displyed on screen (where ISO-8859-1 encoding is used), PHP’s iconv function comes in handy and you can use it like

echo iconv(“UTF-8″,”ISO-8859-1//TRANSLIT”, $temp_item['encoded']);

and this will remove those characters and replace it with the nearest possible character during its tranliteration.

Jun 06
2009

jQuery extension Impromptu

Last updated: June 9th, 2009

This is an easy and elegant way to prompt user messages or to seek user inputs. The author of this tool had cleanly explained its various usage by giving examples which is again easy to follow.

Check out the extension at http://trentrichardson.com/Impromptu/index.php

Jun 05
2009

CakePHP: Parsing RSS feed in Simple Steps

Last updated: June 8th, 2009

How to read RSS feeds (XML file) and display contents in CakePHP?

Parsing an XML feed can be done in simple steps as follows in CakePHP …

CakePHP Controller: /app/controllers/rss_controller.php

<?php
/**
*	CakePHP Controller to parse XML file
*/
class RssController extends AppController{
	var $name = "Rss";
	// As the RSS will not currently use a database
	var $uses = array();
	var $feed_url = "http://kurinchilamp.kurinchilion.com/feed";
	var $rss_item = array();

	function index(){
		App::import('Xml');
		$parsed_xml =& new XML($this->feed_url);
		// xml to array conversion
		$this->rss_item = $parsed_xml->toArray();
		$this->set('data', $this->rss_item['Rss']['Channel']['Item']);
	}
}
?>

CakePHP View: /app/views/rss/index.ctp



Jun 04
2009

CakePHP: Beginners installation hurdles – Errors and Solutions

Last updated: June 4th, 2009

I thought to mention a few errors beginners into CakePHP might come across when configuring CakePHP and how to resolve

Notice: this error is being rendered by the app/views/errors/missing_table.thtml view file, a user-customizable error page.

This error occurs when the database is not configured in cakePhp. First create a database in MySQL or the database of your choice. Go to /app/config/ and make a copy of database.php.default and rename it to database.php. Open database.php and give the necessary settings of the new database created with the associated login credentials. Once that is done, refresh the page and see if that error is now resolved.
(more…)

Jun 03
2009

.htaccess purpose considerations

Last updated: June 3rd, 2009

.htaccess – Purpose, Considerations
.htaccess is a hidden file in the web server which comes in handy when the sites are hosted in shared environment.

Considerations:

Slight hit to performance takes place when .htaccess directive is set as Apache checks each directory for its existence before any file access in that directory

Next consideration will be with regards how the site owners manage the setting changes and its security which can be misused.
(more…)

Jun 02
2009

CakePHP: To Check if Mod_rewrite is Disabled

Last updated: June 4th, 2009

How to check if mod_rewrite is disabled in Apache when CakePHP is installed?
Initially when CakePHP is downloaded from sourceforge and is installed in your localhost, you can test if it is working or not by going to the respective directory in your local host http://localhost/cake.

If CSS styling is missing in the display page, then check apache server’s httpd.conf file to see if mod_rewrite module is enabled. Remove the comment symbol to enable mod_rewrite in your localhost and restart Apache server for the change to take effect
(more…)


Valid HTML 4.01 Strict  Valid HTML 4.01 Strict