Wednesday, September 26, 2012

Drupal Blog Page Not Found

If you have the problem of not being able to see the Blog Module page after enabling it, and you are using Clean URL for your site, then it's *probably* because you have accidentally created a subdomain with the name 'blog' (e.g. http://blog.example.com), or you have a subdirectory named 'blog' on your website's root folder (www, htdocs or public_html). You should be able to see Drupal's Blog Module after you remove the subdomain / subdirectory with that same name.

The reason you cannot view the Blog Module at your website's URL (e.g. http://www.example.com/blog) when you have a subdomain / subdirectory with the same name is because when using Clean URL, Drupal rewrites the Blog Module address (http://www.example.com/?q=blog to http://www.example.com/blog) using .htaccess file. This causes confusion on the webserver, because when we try to access http://www.example.com/blog, it doesn't know which URL it is suppose to display. It could be the URL that Drupal has rewritten, or it could also be the subdirectory that you have in your web root folder.

The same concept also apply with all the URL Aliases that you have created with your Drupal. Make sure you don't have a folder with the same name as your aliases, or else you will get a Page Not Found error.



Thursday, September 6, 2012

Wordpress - Exclude images from showing in the_content() - Resolved

<?php
   ob_start();
   the_content('Read the full post',true);
   $postOutput = preg_replace('/<img[^>]+./','', ob_get_contents());
   ob_end_clean();
   echo $postOutput;
?>

Ref. Link: http://wordpress.org/support/topic/exclude-images-from-showing-in-the_content

Wednesday, September 5, 2012

XML Sitemap generation with php and mysql


<?php
$host = "localhost"; // host name
$user = "user"; // database user name
$pass = "password"; // database password
$database = "dbname"; // database name
// connecting to database
$connect = @mysql_connect($host,$user,$pass)or die (@mysql_error());
// selecting database
@mysql_select_db($database,$connect) or die (@mysql_error());

// default header(don't delete)
header("Content-Type: text/xml;charset=iso-8859-1");
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';

// mytable = your content table name
$query = @mysql_query("SELECT * FROM mytable");
while($row = @mysql_fetch_array($query)){
// [url] = content url
$url = $row['url'];
// [time] = content date
$date = date("Y-m-d", $row['time']);

// NO CHANGES BELOW
echo
    '<url>
     <loc>' . $url .'</loc>
     <lastmod>'. $date .'</lastmod>
     <changefreq>daily</changefreq>
     <priority>0.8</priority>
     </url>
    ';
}
echo '</urlset>';?>



.htaccess code ( Optional )


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
</IfModule>