Jump to content


[Hack] Include/exclude categories from Random Pic block


  • You cannot reply to this topic
No replies to this topic

#1 visiblesoul

  • Administrators
  • 551 posts
  • Location:Earth
  • Texas

Posted 31 May 2006 - 01:31 PM

[Hack] Include/exclude categories from Random Pic block
for Mkportal M1.1 Rc1
by visiblesoul

This hack will allow you to include or exclude individual gallery categories from the random image block. Set the categories to include or exclude in the $catlist variable in the config section of the block.


To include certain categories:

FIND in /mkportal/blocks/random_pic.php:
$content = "";


	
	$count = $this->stats['tot_gallery'];
	$start	=	rand(0, ($count -1));
	$query = $DB->query("SELECT id, titolo, file FROM mkp_gallery where validate = '1' LIMIT $start, 1");
REPLACE WITH:
/*-------------------------------------------------------------------------
Config:
--------------------------------------------------------------------------*/

$catlist = "1,2,3,4,5";	// List gallery category IDs to get images from. Separate IDs with commas

/*------------------------------------------------------------------------*/
$content = "";

	$catquery = $DB->query("SELECT id FROM mkp_gallery WHERE evento IN ($catlist)");
	$count = $DB->get_num_rows ($catquery);
	$start	=	rand(0, ($count -1));
	
	$query = $DB->query("SELECT id, titolo, file, evento FROM mkp_gallery WHERE validate = '1' AND evento IN ($catlist) LIMIT $start, 1");
FIND:
	unset($thumb);
ADD BELOW:
	unset($catlist);
	unset($catquery);
------------------------------------------

To exclude certain categories:

FIND in /mkportal/blocks/random_pic.php:
$content = "";


	
	$count = $this->stats['tot_gallery'];
	$start	=	rand(0, ($count -1));
	$query = $DB->query("SELECT id, titolo, file FROM mkp_gallery where validate = '1' LIMIT $start, 1");
REPLACE WITH:
/*-------------------------------------------------------------------------
Config:
--------------------------------------------------------------------------*/

$catlist = "1,2,3,4,5";	// List gallery category IDs to get images from. Separate IDs with commas

/*------------------------------------------------------------------------*/
$content = "";

	$catquery = $DB->query("SELECT id FROM mkp_gallery WHERE evento NOT IN ($catlist)");
	$count = $DB->get_num_rows ($catquery);
	$start	=	rand(0, ($count -1));
	
	$query = $DB->query("SELECT id, titolo, file, evento FROM mkp_gallery WHERE validate = '1' AND evento NOT IN ($catlist) LIMIT $start, 1");
FIND:
	unset($thumb);
ADD BELOW:
	unset($catlist);
	unset($catquery);



Please note that I offer free support on this forum in my free time. Depending on how much work I have backlogged it may take me a week or more to answer questions. I am not ignoring you. I answer everyone but please be patient. Thanks.

Disclaimer: All forum posts, including code examples, on this forum are offered for free in the hope that they will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Use code examples at your own risk.

"If at first you don't succeed, keep on suckin' til you do succeed." -Curly Howard





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users