External Master Badges | v1.0 | etcgfm v1.0.1 | up 10.28.13

  1. 4 years ago

    Required Mods
    Set Badge fix (not yet added to Filler00)

    Purpose
    This allows you to separate your master badges from your cards. This is basically for if you want to (a) separate your master badges and your cards, or (b) you're allowed to direct-link the cards, but the master badges either can't be direct-linked, or are direct-linked at a different URL.

    (For example, on Tiny Legend, I used to direct-link the cards, but at the time, they didn't have master badges--or when they did, I preferred Suza's--so I used this code so I could show my own badges.)

    Note, you WILL have to upload your master badges to your server if they aren't already uploaded to where you're going to link them from.

    Function
    This goes into your func.php, custom function page, or any pages that you will use the function on.

    function external_badges($tcg, $url, $worth = '', $deckname = '') {
    	
    	$database = new Database;
    	$sanitize = new Sanitize;
    	$tcg = $sanitize->for_db($tcg);
    	
    	$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
    	$tcgid = $tcginfo['id'];
    	$cardsurl = $url;
    	$format = $tcginfo['format'];
    	
    	if ( $worth !== '' ) { $worth = intval($worth); }
    	if ( $deckname !== '' ) { $deckname =  $sanitize->for_db($deckname); }
    	
    	if ( $worth !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = 
    
    '$tcgid' AND `mastered` = '1' AND `worth` = '$worth' ORDER BY `mastereddate`"); }
    	else if ( $deckname !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE 
    
    `tcg` = '$tcgid' AND `mastered` = '1' AND `deck` = '$deckname' ORDER BY `mastereddate`"); }
    	else { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND 
    
    `mastered` = '1' ORDER BY `mastereddate`"); }
    	while ( $row = mysql_fetch_assoc($result) ) { 		
    		$mastered = date('F d, Y', strtotime($row['mastereddate']));
    		if ( $row['badge'] !== '' ) { echo '<img src="'.$url.''.$row['badge'].'" alt="" 
    
    title="Mastered '.$mastered.'" /> '; }
    	}
    	
    }

    Execution
    Place this wherever you want the list to go.

    function external_badges($tcg, $url, $worth = '', $deckname = '')

    The reqired variables to change are $tcg, to whatever TCG you're using it on; $url to wherever your cards are. REMEMBER THE TRAILING SLASH! For example: 'http://post.domain.com/tcg/mastered/'

    The optional variables are $worth (which only shows mastered decks of a given worth) and $deckname (only gives them by deckname).

    Upcoming Versions
    Nothing planned at the moment. Suggestions welcome, though.

or Sign Up to reply!