PHP

How to Host Static & Dynamic Page (PHP) in Windows Server 2008 R2

This is just a summary on how to host static & dynamic page in Windows Server 2008 R2. For detail’s guide click on the link in the step by step guides below. Credit to TrainSignal for the detail’s guides.

  1. Install Internet Information Services (IIS)
  2. Install PHP
  3. Install MySQL Database

After completion, you should be able to host static & dynamic page. Dynamic website such as WordPress should work well.


Add Related Listings in phpMyDirectory

In WordPress, related post plugin is very good to get visitors to read more or your blog & reducing bounce rate. If you want to have the same function in phpMyDirectory, need to add the following code.

Update : For phpMyDirectory version starting 1.4.3, you no longer have to edit “listing.php” file. This feature includes by default. You only need to edit “listing_default.tpl” if the template does not include this feature.

1. “listing.php” in phpMyDirectory installation

Find the following code

$PMDR->get('Statistics')->insert('listing_impression',$listing['id']);

Add the following code directly above it

// Related Listing start
if(!$related_listings = $PMDR->get('Cache')->get('listing_related_'.$listing['id'], 2592000)) {
    $related_listings = $db->GetAll("SELECT id, title, friendly_url, MATCH(title, description_short, keywords) AGAINST('".$listing['title']." ".$listing['keywords']."') AS score
    FROM ".T_LISTINGS."
    WHERE MATCH(title,  description_short, keywords) AGAINST('".$listing['title']." ".$listing['keywords']."') AND id!=?
    ORDER BY score DESC LIMIT 10",array($listing['id']));
    if(is_array($related_listings)) {
       foreach($related_listings AS &$related_listing) {
          $related_listing['url'] = $PMDR->get('Listings')->getURL($related_listing['id'],$related_listing['friendly_url']);
       }
    }
    $PMDR->get('Cache')->write('listing_related_'.$listing['id'],$related_listings);
}
$template_content->set('related_listings',$related_listings);
// Related Listing end

2. “listing_default.tpl” in template folder.

Add the following code where you want to display the Related Listing

<h2>Related Listings</h2>
<?php if($related_listings) { ?>
   <strong>
     <?php foreach($related_listings AS $related_listing) { ?>
     <li><a href="<?php echo $related_listing['url']; ?>"><?php echo $related_listing['title']; ?></a></li>
     <?php } ?>
   </strong>
<?php } ?>