Installing Card Manager

As any player of Online Trading Card Games — TCGs — will know, there are only three options for managing your own trading post:

  1. Do it manually.
  2. Use Card Manager, a PHP script created by Mandi.
  3. Use Trade Post Manager, a PHP script created by Marfisa.

In my opinion, the best option here is to use Card Manager. My reasons are thus:

  • Using Card Manager requires you to have a full copy of your tradepost on your own computer — loss of either your website or own hard drive data can be easily remedied by simply copying from one place to another. Trade Post Manager does not require any kind of backup, and it would be pretty easy to lose track of your work if your website disappeared for any reason.
  • Doing it manually can be extremely time-consuming, and can easily make updating a chore rather than a hobby. I found that taking time to figure out how to use Card Manager was definitely worth it. :)

I also just didn’t require a complete Trade Post Manager and preferred to use the features of Card Manager. So, if you’d like to use Card Manager too, keep reading because I’m going to attempt to explain how to install it.

Prelimary

During this tutorial, I will be assuming that you are familiar with FTP (I recommend Georgina’s tutorial) and that you have PHP-compatible webspace (I recommend Bubble.nu).
If you get stuck at any point, please don’t hesitate to leave a comment. I can’t help you if I don’t know you’re having a problem; and I would like to help you! If you know me through Twitter, feel free to drop me a line on there as well. :)

Step One: Download Card Manager.

  1. Visit the Card Manager download page: http://scripts.enchanted-rose.net/cm/download.php
  2. Follow the instructions, or if in doubt, just download one of everything to a folder of your choice. Got it? I’ve put mine in a folder called “tcg”. Please note: You need to right-click on the link to the file and “save target as”, “save link as” or “save file as”; clicking on the link normally to view in the browser and then using “save page as” could result in a mangled file.
  3. Now you need to make sure that all of the ‘.txt’ files are renamed to ‘.php’ — this means that cardmanager.txt, cardcount.txt, config.txt and index.txt need to become cardmanager.php, cardcount.php, config.php and index.php. If you cannot see the file extensions, try viewing the files with the FTP client. :)

The rest of the tutorial will be in the same order as the readme.txt which you have just downloaded — I recommend reading that first, and then reading the appropriate section of this tutorial if you need any clarification. There are also explanations inside each of the .php files, and I recommend reading those as well. :)

Step Two: Create Folders

In order to make things easier when you eventually join multiple TCGs (it’s hard to resist once you’ve started, trust me!) we’re going to create a new folder inside our tcg folder. For my example I’m going to use cards from Choices, so my folder will be called choices. If you’d like to use a different TCG, just create a folder named after that instead. Once you’ve created that folder, copy config.php and index.php into it but leave everything else where it is – in the tcg folder.

According to the readme.txt which we’ve just downloaded, the next step is to organise all of your cards into folders. A quick look inside config.php shows that the default folders are collecting, mastered, future, maybe, trading, pending and special. Those are a good starting point, but we need a filler folder (to hold the blank ‘filler’ cards for our collecting sets) and two more special folders (create one inside future, one inside pending and put one inside trading) for most TCGs. Create those folders inside choices (or whichever TCG you’re creating a post for) and then compare it to this image:

If you’re not quite with me, just create/rearrange your folders so that they’re in the order shown in the image and then make sure that there are copies of config.php and index.php inside the choices folder. :)

Step Three: Organise Your Cards

If you’re a member of a TCG, use your own cards and sort them into the correct folders above. If you haven’t joined any yet, I suggest saving the cards on my Example Trading Post, which I’m creating as I write this tutorial. Here’s a description of each folder:

  • Collecting. When you register at a TCG, you usually have to declare which deck you’re going to collect first. Put any cards from the deck(s) you are collecting inside the collecting folder.
  • Future. This folder is for cards from any decks you plan to collect in the future and don’t want to trade away. Simple! :)
  • Mastered. Pretty much what it sounds like – this is for any decks you have completed.
  • Maybe. I don’t use this folder, but it’s for cards you want to collect, but will trade for cards from your collecting decks.
  • Special. Most TCGs have ‘special’ decks, which have a higher card worth than the normal cards. Those cards need to go in the special folders.
  • Trading. Any cards which you aren’t collecting and are happy to trade for just about anything!
  • Pending. If you make a trade offer to somebody, put the cards you’ve offered inside pending so nobody else will ask for them.

It should be fairly easy to sort your cards out now — if you want any extra folders (ie specific categories inside trading, or a members folder for member cards), just create them at this stage and I’ll show you how to add them to your post later in the tutorial. :)

Step Four: Editing config.php

Open the copied config.php (should be in choices or your equivalent) in Notepad or Notepad++ and edit the variables. These are all explained quite clearly, so I’ll just include hints for parts which may confuse less experienced readers. :)

$cardcount = "/home/YOURDOMAIN/public_html/YOURSUBDOMAIN/FOLDERS/cardcount.php";
For this part you need to find out your home directory — you can do this using a PHP file — create a blank file, copy and paste the following, and then upload it.
<?php echo dirname(__FILE__); ?>
When you view the uploaded file in your browser, it will display your full path. Alternatively, if you’re using cPanel then you can find this by logging in and looking under “stats” in the left column. This will probably be /home/[username] — if your username is flower and you’re putting your Trading Post at yourwebsite.com/tcg/ then the exact location of your cardcount.php will be:
$cardcount = "/home/flower/public_html/tcg/cardcount.php";

Next you’ll need to change your collecting sets. For my example trading post, I’m collecting ootp-sirius, which has 15 cards and is worth 1. I can see from the Choices card page that it’ll look good in rows of 5, so that’s how I will display it too. It’s also not a puzzle deck. In this case, my $collecting array would look like this:

$collecting = array(
	            array(Name => "ootp-sirius", Worth => "1", Num => "15", Row => "5", Puzzle => "no"),
		    );

The mastered decks array works in the same way — once you’ve finished collecting a deck, just copy that line from $collecting and put it in the $mastered array. For my example it would look like this:

$mastered = array(
		  array(Name => "ootp-sirius", Worth => "1", Num => "15", Row => "5", Puzzle => "no"),
		  );
Next, the $directories array! To begin with, it looks something like this:
$directories = array(
			array(Folder => "future/", Section => "Future Collecting", Worth => "1", Page => "1"),
			array(Folder => "maybe/", Section => "Might Trade", Worth => "1", Page => "2"),
			array(Folder => "trading/", Section => "Trading", Worth => "1", Page => "2"),
			array(Folder => "special/", Section => "Specials", Worth => "2", Page => "1"),
			array(Folder => "trading/pending/", Section => "Pending", Worth => "1", Page => "3"),
		     );
If you wish to add more folders here, simply add another line and fill it with the appropriate information. For example, to create a ‘special’ section to my ‘future’ page, I would create the special folder inside future and then add this line:
array(Folder => "future/special/", Section => "Future Special", Worth => "2", Page => "1"),

You can also use this section to rearrange the pages on your Trading Post — in conjunction with the menu section which you’ll find at the bottom of the config.php file. After adding the folders we created earlier, the array should look like this:

$directories = array(
		array(Folder => "future/", Section => "Future Collecting", Worth => "1", Page => "1"),
		array(Folder => "future/special/", Section => "Future Special", Worth => "2", Page => "1"),
		array(Folder => "maybe/", Section => "Might Trade", Worth => "1", Page => "2"),
		array(Folder => "maybe/special/", Section => "Might Trade: Special", Worth => "2", Page => "2"),
		array(Folder => "trading/", Section => "Trading", Worth => "1", Page => "2"),
		array(Folder => "trading/special/", Section => "Trading Specials", Worth => "2", Page => "2"),
		array(Folder => "pending/", Section => "Pending Trades", Worth => "1", Page => "3"),
		array(Folder => "pending/special/", Section => "Pending Special", Worth => "2", Page => "3"),
		);
Note that for everything which is set to appear on the same page, they will display in the order above, i.e. Future Collecting will appear before Future Special.
The rest of the file is explained fairly well, and I’ll let you read through that yourself. If you don’t understand something, try reading it again – it might make more sense on the second go. If you get really stuck, let me know (comment or email) and I’ll amend the tutorial to explain.
Read through the rest of the file without me and edit everything you need to. I would ignore $introduction if I were you, or even make it blank (as I have done with my own file) — I’ll explain why later.
Scroll down to the bottom of the file and you’ll find the $pageTitles array, which currently looks like this:
$pageTitles = array (
		array(Num => "1", Title => "Keeping"),
		array(Num => "2", Title => "Trading"),
		array(Num => "3", Title => "Pending Trades"),
		array(Num => "4", Title => "Mastered"),
		array(Num => "", Title => "Index"),
		);
This is the section that creates the pages and menu — if you’d like to move things to separate pages, create those pages in this section first and then go back up to the $directories array to edit individual page variables. I’m going to rearrange this section a little bit to suit the folders I’ve already created, so my file will look exactly like this:
$pageTitles = array (
	array(Num => "1", Title => "Collecting"),
	array(Num => "2", Title => "Future"),
	array(Num => "3", Title => "Trading"),
	array(Num => "4", Title => "Pending"),
	array(Num => "5", Title => "Mastered"),
	array(Num => "", Title => "Index"),
	);

If you’ve added any extra pages (like splitting maybe and trading), you’ll need to go back up to the $directories array and update all the page numbers to match this new set-up, remembering to leave page numbers for collecting and mastered. Always make sure that each page has a different number. When you add or remove pages, remember to adjust the variables just above this section – particularly $pages. These links also appear in the order they do in the file – if you want the index link first, just move the line to the top of the array.

Right beneath this section are the menu variables. Again, these are well explained and the only one I am editing for now is $last because I want to add a link to my trade form. I am changing it to this:
$last = "&nbsp;|&nbsp;<a href='trade.php'>Trade?</a>";
In case you can’t tell, that is: [space] [separator (same as used in $end to make this fit in)] [space] [link to trading form]
Note: Don’t use any quotation marks here, unless you ‘escape’ the character first by putting a slash in front of it: \”
You can add whatever links you would like to your menu by altering $first and $last – just don’t forget to add whatever separator you’ve defined in $end. :)

Step Three: Editing Index.php

Open the copied index.php (should be in choices or your equivalent) in Notepad or Notepad++ so we can edit it to our liking. Go ahead and change the title of the page to whatever you’d like. I’m calling mine ‘Example Trade Post’, because I am highly original. If you downloaded a CSS stylesheet when downloading Card Manager, let’s add that now. I’m going to use cards-pink.css which is still in the tcg folder. Because it’s in a folder one step above the one this index.php is inside, I’ll have to add “../” to the beginning of the filename so it knows where to look for it. Let’s do that now. I’ll change this:
	<?php include("cards.css"); ?>
to this:
	<?php include("../cards-pink.css"); ?>
and then I need to make sure it’s looking for cardmanager.php in the right place, so I’ll add “../” to that as well – changing this:
	<?php include("cardmanager.php"); ?>
to this:
	<?php include("../cardmanager.php"); ?>
Now that everything’s pointing to the right places, we can edit this file to create our final look. If you would like your profile information to appear on every page, just replace this page of the page with whatever you’d like:
	<p><a href="http://daisykitten.net/animals/"><img src="badge.gif" border="0" alt="Kingdom Animalia"></a></p>

	Card count: <b><?php print($total1)?></b><br>
	Card worth: <b><?php print($total2)?></b><br>
If, however, you’d like it to only appear on your index page, follow me! :)
Let’s look at the credit section:
	<!-- Credit link, please do not remove unless you are crediting me on another page. This link only apears on the index page. -->

	<?php if(!$_GET['page'] && !$_GET['set']) {echo "<p align='center'><font style='font-size: 8pt'>[Powered by <a href='http://scripts.enchanted-rose.net' target='_blank'>Card Manager</a>]</font></p>";}?>

	<!-- End of credit link. -->
Note that it clearly states the credit link will only appear on the index page. Well, we want our introduction and profile information to only appear on the index page, right? So this is where we’re going to put it. We’ll keep the credit link but we’ll put our own introduction above it. We need to open up that part of the PHP so we can put anything in this section! To do this quickly, just replace the above section with this:
<!-- Credit link, please do not remove unless you are crediting me on another page. This link only apears on the index page. -->

	<?php if(!$_GET['page'] && !$_GET['set']) { ?>
	<!-- PUT YOUR INDEX PAGE HERE -->
	<p align="center"><font style="font-size: 8pt">[Powered by <a href="http://scripts.enchanted-rose.net" target="_blank">Card Manager</a>]</font></p>

		<?php } ?>

	<!-- End of credit link. -->
As you may have guessed, you can put whatever you’d like in the space which says PUT YOUR INDEX PAGE HERE. :) You may also remove the credit link comments, and even remove the credit link entirely if you’d like to recode it yourself. If you’re using this area, you might want to remove paragraph and card count/card worth snippets in the text I highlighted above and put them inside this area. I’ve changed the image to my Choices member card:
	<!-- Credit link, please do not remove unless you are crediting me on another page. This link only apears on the index page. -->

		<?php if(!$_GET['page'] && !$_GET['set']) {?>

		<p><a href="http://choices.dustysky.net/"><img src="Jennifer-mc.png" border="0" alt="Choices"></a></p>

		Card count: <b><?php print($total1)?></b><br>
		Card worth: <b><?php print($total2)?></b><br>

		<p align="center"><font style="font-size: 8pt">[Powered by <a href="http://scripts.enchanted-rose.net" target="_blank">Card Manager</a>]</font></p>

		<?php } ?>

	<!-- End of credit link. -->

Let’s leave this as it is for now, and upload everything to your webspace so you can see how it works and customise it in your own way. I hope you’re feeling confident in using this script now, but if you have any questions at all simply leave a comment on this page and I’ll do my best to help you. :)

P.S. You can view my real Trading Post, powered by Card Manager, here: tcg.fangirl.co.uk :)

2 Responses

  1. Siouxsie
    Siouxsie Monday, November 28th, 2011 at 12:07pm (UTC) | | Reply

    I just wanted to thank you for this! I think I found it via Google search? Anyway, I had never used a card manager before and I really had no idea what I was doing any I finally got it to work. You have some neat tricks like the “../”

    And this: Note: Don’t use any quotation marks here, unless you ‘escape’ the character first by putting a slash in front of it: \”

    The helped when I broke everything :)

    The only thing that might help is I had to cheat and read Marfisa’s to find my home directory. The part here called PHP FINDS YOUR FULL PATH! http://clavis-sama.com/tutorials.php?php

    Yay, now onward to a life of never counting cards or manually editing again!

Leave a Reply