Tutorials

Add each FL member count to Flinx Collective

So, you use PHPFanBase for all of your fanlistings and you use Flinx Collective on for fanlisting’s collective. And, you have seen that some people, like Sasha and myself, that have each individual fanlisting member count with the fanlisting description, in the category.php page of Flinx. Have you ever wondered how you could do that?

Okay, before we get started, let me just say that there are many ways of doing this. Most of them require some serious Flinx hacking, which means modifying pretty much every file, changing the tables structures, and re-installing Flinx. Well, that’s not what we are gonna do here. This is the easiest way to do this that I could come up with, and, because I’ve tried to keep it as simple and fast as possible, it does have a few limitations.

  1. All your fanlistings have to be running PHPFanBase.
  2. All your fanlistings must be hosted on the same domain.
  3. All your fanlistings URLs have to follow some kind of pattern. By this I mean: either they are subdomains (such as http://fanlisting1.domain.com, http://fanlisting2.domain.com, and so on), OR they are folders within the domain (such as http://domain.com/fanlisting1, http://domain.com/fanlisting2, or even http://domain.com/category/fanlisting) or they are folders within the same subdomain (such as http://fan.domain.com/fanlisting1, http://fan.domain.com/fanlisting2, etc). You can’t have some that are folders and some that are subdomains. It just won’t work. You will understand why later.
  4. You have to be using Flinx Collective.
  5. Make sure you have a copy of your current category.php file (from Flinx Collective), because, if something goes wrong, you are safe.

Okay, do your fanlistings and your collective follow the requirements? Have you made a copy of your current category.php file? Yes? Good, now we can get started.

First of all, let’s write the code you will need. Where are your fanlistings? Are they folders or subdomains? The code is a little bit different for each, so if they are subdomains, scroll down. If they are folders within the domain (such as http://domain.com/fanlisting1, http://domain.com/fanlisting2, or even http://domain.com/category/fanlisting) or folders within the same subdomain (such as http://fan.domain.com/fanlisting1, http://fan.domain.com/fanlisting2, etc), open a new file in notepad, and copy and paste this:

<?php
$path = ereg_replace("http://(sub.)domain.com", "/path/to/(sub)domain", $row['url']);

require $path . '/config.php';

$query1 = mysql_fetch_assoc(mysql_query('SELECT COUNT(id) AS num FROM ' . $table . " WHERE apr = 'y'"));
$query2 = mysql_fetch_assoc(mysql_query('SELECT COUNT(id) AS num FROM ' . $table . " WHERE apr = '-'"));
?>
<b>Members:</b> <?php echo $query1['num']; ?><br />
<b>Pending:</b> <?php echo $query2['num']; ?><br />

<?php $query3 = mysql_fetch_assoc(mysql_query('SELECT date FROM ' . $table_u)); ?>

<b>Last update:</b> <?php echo $query3['date']; ?>

Okay, now you have to edit the second line, which is this one:

$path = ereg_replace("http://(sub.)domain.com", "/path/to/(sub)domain", $row['url']);

Let me tell you exactly what you have to change. This is the most tricky part, so pay close attention. Where it says http://(sub.)domain.com, you have to write either the domain or the subdomain where all your fanlistings are hosted. Then, where it says /path/to/(sub)domain, I need you to write the full path to that same domain or subdomain. Be careful! Remember to write both WITHOUT a slash at the end! If you didn’t get this already, what we are trying to do is get the path to your fanlisting config file. I’m just using the fanlisting URL to extract only the folder name, so we can include the config file, which is needed to show your members.

Now, open up category.php (not your "safety copy", the other one!). Look for the part where it displays your fanlisting info (somewhere around lines 75-80). They have something like this:

<b>Title:</b> <?=$row["title"]?><br>
<b>Subject:</b> <?=$row["subject"]?><br>

<b>Opened:</b> <?=$row["date"]?><br>
<i><?=$row["description"]?></i>

Where do you want your total current members, pending members and last updated date to go? Let’s say you want it after the opening date and before the description. Then just copy the code we wrote, and paste it right there! That’s all!

Oh, but your fanlistings URLs are not folders, they are subdomains? Okay, then copy this code into a blank notepad file:

<?php
$folder = dirname($row['url']));
require '/path/to/your/domain/' . $folder . '/config.php';

$query1 = mysql_fetch_assoc(mysql_query('SELECT COUNT(id) AS num FROM ' . $table . " WHERE apr = 'y'"));
$query2 = mysql_fetch_assoc(mysql_query('SELECT COUNT(id) AS num FROM ' . $table . " WHERE apr = '-'"));
?>
<b>Members:</b> <?php echo $query1['num']; ?><br />
<b>Pending:</b> <?php echo $query2['num']; ?><br />

<?php $query3 = mysql_fetch_assoc(mysql_query('SELECT date FROM ' . $table_u)); ?>

<b>Last update:</b> <?php echo $query3['date']; ?>

Okay, now you have to edit the third line, which is:

require '/path/to/your/domain/' . $folder . '/config.php';

I need you to change “/path/to/your/domain” to the, well, full path to the domain, and leave everything after that the same. If you didn’t get this already, this is the path to your fanlisting config file. I’m just using the fanlisting URL to extract only the subdomain name (and, at the same time, the folder), so we can include the config file, which is needed to show your members.

Now, open up category.php (not your "safety copy", the other one!). Look for the part where it displays your fanlisting info (somewhere around lines 75-80).
They have something like this:

<b>Title:</b> <?=$row["title"]?><br>

<b>Subject:</b> <?=$row["subject"]?><br>
<b>Opened:</b> <?=$row["date"]?><br>

<i><?=$row["description"]?></i>

Where do you want your total current members, pending members and last updated date to go? Let’s say you want it after the opening date and before the description. Then just copy the code we wrote, and paste it right there! That’s all!

Comments

Error Comments are closed for this entry.