htaccess Redirect Based On Broswer Language
Jun 30th
For some reason, qTranslate is not redirecting my blog properly for different language. Therefore I use mod rewrite on .htaccess to perform the redirect.
Add the following line to your .htaccess file
<IFModule mod_rewrite.c>
RewriteEngine On
# Set the base path here
RewriteBase /
# Only redirecting Chinese such as zh-CN, zh-HK, etc.
RewriteCond %{HTTP:Accept-Language} ^zh [NC]
# I use query strings for getting language setting
RewriteRule ^$ /index.php?lang=zh [L]
</IFModule>
Twitter is broken on Mystique
Jun 29th
I have no idea why the built-in Twitter widget is broken on my Mystique theme. It’s working just fine when I host the my WordPress blog on my own computer using XAMPP. Somehow it’s just broken. It may or may not have something to do with the compatibilities of other plugins, like qTranslate. I might get it fixed later, but for now I am really tired of any PHP code after working 8 hrs on a PHP project. My brain just need to rest~!
Using query_posts() to prepare posts for your template
Jun 28th
When creating your own template, you may need to use WP built-in function, query_posts(), to prepared the posts to display. There are a lot you can do with query_posts(), but I will only mention some simple cases here.
For single category or tag template
1. Build the list of arguments for query_posts() . For the complete list of arguments, please visit wordpress.org
$args=array(
'cat'=>$p, //$p is the category id
//'tag'=>$t, //$t is the tag id
'paged'=>$paged, //$paged is the global variable containing the page number
);
2. Prepare the posts
query_posts($args);
3. Display the posts
while (have_posts()):
the_post();
include(TEMPLATEPATH . '/post.php');
endwhile;
4. Display pagenavi
if you have installed the WP-pagenavi plugin and want to integrate it into your template, add the following lines to the proper position
<div class="page-navigation clearfix">
<?php if(function_exists('wp_pagenavi'))wp_pagenavi(); ?>
</div>
Set Up Remote PHP Project In Netbeans
Jun 15th
With PHP plugin in Netbeans, it’s possible to set up a remote project. With a remote project, you can see the actual result of your website any time you want. It gives you instant feedback of what your website will look like, and saves you tons of trouble for migrating your project if the project is developed in localhost. It also provides files/code synchronization. It’s very similar to any source control system like cvs or svn except it lacks the rollback feature.
Step 1:
Create a new PHP Project, Netbeans->File->New Project->PHP->PHP Application From Remote Server
Step 2:
Enter the project information(Project name, PHP version, and source folder)
Step 3:
Enter the remote url, either the complete url or the IP address of the remote host, click Manage to add/modify remote connection.
Step 4:
Enter the FTP connection information. Click OK to return to Step 3, then finish the setup. If the connection is successfully set up, files will be downloaded from the remote server.
Step 5:
Configure the project, Project->Properties->Run Configuration. Make sure Run As Remote Web Site(FTP,SFTP). Upload mode can be changed in the Upload Files field.(On Save recommended).
Step 6:
Done~!
Adding PHP Development Support to Netbeans
Jun 8th
As Netbeans and Eclipse are two of the greatest java development IDE, they both support PHP development via plugins. Netbeans has been my most recent IDE for web development. It’s one of the best HTML/CSS editor/IDE recently. PHP development in Netbeans is also plausible.
Software Needed:
1)Netbeans
2)Apache Web Server/MySQL/PHP
3)Xdebug
Steps:
-> Download and install Netbeans
Get Netbeans for PHP is you are only using Netbeans for PHP development.
If you already have Netbeans installed, go to Tool->Plugins, search and install PHP plugins
-> Installing Apache/MySQL/PHP
The easiest way to get Apache/MySQL/PHP is to install the AMP package. Common AMP package includes XAMPP, SAMP, LAMPP, WAMP. I would recommend XAMPP since it’s cross platform, meaning it can be used on different OS platform.
->Installing And Configuring Xdebug
Xdebug is currently the best debugging tool for PHP development. First, Download Xdebug. For Windows, it’s a .dll file.
To integrate Xdebug into XAMPP,
a) Copy the .dll file to xampp\php\ext
b) Append the following line to xampp\php\php.ini
//replace php_xdebug-2.1.0RC1-5.3-vc6.dll with your version of Xdebug zend_extension = "your_xampp_directory\php\ext\php_xdebug-2.1.0RC1-5.3-vc6.dll" xdebug.remote_enable=1
-> Configuring Netbeans
Tool->Option->PHP, locate the PHP5 Interpreter. (“xampp\apache\bin\httpd.exe”)




