https://s3-us-west-2.amazonaws.com/secure.notion-static.com/514b5766-91be-4f03-85b7-be915805db30/Untitled.png

Add the following code to your mods.php file, between the PHP tags.

ADD TO MODS.PHP, between the PHP tags

// Show cards from the given category, returns text.
function show_cards_as_text( $tcg, $category, $unique = 0 ) {

	$database = new Database;
	$sanitize = new Sanitize;
	$tcg = $sanitize->for_db($tcg);
	$category = $sanitize->for_db($category);
	$altname = strtolower(str_replace(' ','',$tcg));
	
	$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
	$tcgid = $tcginfo['id'];
	$cardsurl = $tcginfo['cardsurl'];
	$format = $tcginfo['format'];
	
	$cards = $database->get_assoc("SELECT `cards` FROM `cards` WHERE `tcg`='$tcgid' AND `category`='$category' LIMIT 1");
	
	if ( $cards['cards'] === '' ) { echo '<p><em>There are currently no cards under this category.</em></p>'; }
	else {
		
		$cards = explode(',',$cards['cards']);
		if ( $unique == 1 ) { $cards = array_unique($cards); }
  
    $card_list = array();
		foreach ( $cards as $card ) {
			
      $card = trim($card);
      array_push($card_list, '<span title="' .$card. '">'.$card.'</span>');
		
    }
    $card_list= implode(', ',$card_list);
    echo $card_list;
		
	}

}

DISPLAY CATEGORIES ON PAGES

<?php show_cards_as_text('nameoftcg','nameofcategory'); ?>

Replace your cardsearch.js file

/*------------------------------------------------
	By Daggles, Modified by Caitlin
	<http://tcg.daggles.net/>
	Modify and redistribute as you see fit
	
	12/30/2019: 2.0
		- The ability to search for multiple cards at once was added
	11/17/2011: 1.1
		- Cards in the found list are now links that will take you directly to the card
	11/15/2011: 1.0
		Initial release
------------------------------------------------*/

function repl(str) {
    return $.trim(str.replace(/(?=[\\/\\\\^$*+?.()|{}[\\]])/g, ' '));
}
function clearHighlight() {
	$('img').each(function(index) {
		$(this).removeClass('dimmedCard, highlightCard');
	});
}
function highlightImage() {
	var searchTerm = repl($('#search').val());
	var searchTermArray = searchTerm.split(', ');
	var re = new RegExp(searchTerm  + "[a-zA-Z]*[0-9]*", "i");
	var cardArray = new Array();
	
	if (searchTerm.length >= 3) {
		$('#cardlist').text('');
		$('img').each(function(index) {
      	$(this).removeClass('highlightCard').addClass('dimmedCard');
			for (var i = 0; i < searchTermArray.length; i++) {
				if ($(this).attr('title') != undefined) {
					if ($(this).attr('title').match(searchTermArray[i].toLowerCase())) {
						$(this).addClass('highlightCard').removeClass('dimmedCard');
						cardArray.push('<a href="#' + $.trim($(this).attr('title')) + '">' + $.trim($(this).attr('title')) + '</a>');
						$(this).attr('id', $.trim($(this).attr('title')));
					}
				}
			}
		});
		
			$('span').each(function(index) {
			for (var i = 0; i < searchTermArray.length; i++) {
				if ($(this).attr('title') != undefined) {
					if ($(this).attr('title').match(searchTermArray[i])) {
						cardArray.push('<a href="#' + $.trim($(this).attr('title')) + '">' + $.trim($(this).attr('title')) + '</a>');
						$(this).attr('id', $.trim($(this).attr('title')));
					}
				}
			}
		});
	var cardArrayCount = cardArray.length;
	$('#cardlist').html('<i>Found ' + cardArrayCount + ' cards.</i><br />' + cardArray.join(', '));
	} else {
		$('#cardlist').html('<i>Please enter 3 or more characters.</i>');
	}
}
function clearHighlight() {
	$('img').each(function(index) {
		$(this).removeClass('highlightCard dimmedCard');
		$('#cardlist').text('');
	});
}