phpMyDirectory

How to Disable Statistic Data Collection in phpMyDirectory?

phpMyDirectory statistic data take a huge chunk of database space in MySQL. If you do not require the data, it is wise to disable the data collection as well.

To disable you have to edit the following file.

/includes/class_statistics.php

Find the following code

 if(BOT) {
 return false;
 }
 

and change it to

 if(true) {
 return false;
 }
 

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 } ?>