Taken in 2008 @ shanghai
Archive for October, 2009
cross road
If you are hosting multiple cakephp websites TOGETHER with your wordpress in one single domain, you might encountered some errors or incorrectly display css or images in your cakephp web application.
This is due to the default mod_rewrite rules that come with cakephp installation as it is assume that the application is running for one domain name only.
Fortunately, it is possible to amend that mod_rewrite rules to allow apache to customise different routes for different applications.
Before I explain on how to do it, lets see how I configure entroducing.com
www.entroducing.com -> will call default wordpress (this blog)
www.entroducing.com/project/app1-> will run app1 cakephp
www.entroducing.com/project/app2> will run app2 cakephp
In the webroot folder of your cakephp application, edit the .htaccess file and add the following line
RewriteBase /[subdirectory]/[applicationname]
And it should looks like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /project/stepup
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
Save the file and test your application. It should works fine now.
Just when I was posting source code in my previous post, I realised that my newly installed wordpress does not format the source code nicely. (Read: I’m new to WordPress!)
Nevertheless, I google out and finally able to post source code in my blog.
Here’s how.
- Download Plugin: Go to SyntaxHighlighter Plugin Page and download the plugin
- Upload Plugin: Extract all files from the ZIP file, making sure to keep the file/folder structure intact, and then upload it to
/wp-content/plugins/. - Activate Plugin: Go to the admin area of your WordPress install and click on the “Plugins” menu. Click on “Activate” for the “SyntaxHighlighter” plugin.
And here’s how to use it
When creating a new post, toggle to HTML view.
If the source code you want to use is in javascript, type…
["language"]alert(‘hello world’);[/ "language"]
in that view. Replace the above “language” with the language of your choice. In this case, it is replaced with “javascript” (For full supported language, visit author website.)
And it should display like the below.
alert('hello world');
I was assigned with a mini project to do a team notice board that read XML files using Spry.
While reading plain text in the XML is straightforward, reading of HTML codes like <br> tag, <b> tag are not.
<?xml version="1.0" encoding="utf-8"?> <posts> <post> <msg>This is a <strong>message</strong></msg> </post> </posts>
<msg>This is a <strong>message</strong></msg>
When you type these tags(e.g. strong tag as above) in the XML, it simply ‘breaks’ the XML formatting and would thus caused an error when it is loaded with Spry
So… to input HTML data in XML…
1. Use CDATA wrapper in your XML
<msg> <![CDATA[ This is a <strong>message</strong> ]]> </msg>
2. Set setColumnType(“msg”, “html”) to your Spry dataset for that field
var ds1 = new Spry.Data.XMLDataSet("data.xml", "posts/post");
ds1.setColumnType("msg", "html");




