TinyPortal

Development => Block Codes => Topic started by: HaxXxoR on September 19, 2006, 06:50:04 PM

Title: SMF Gallery Block
Post by: HaxXxoR on September 19, 2006, 06:50:04 PM
Does anyone know how to make a Block that will show the latest image for SMF Gallery???
Title: Re: SMF Gallery Block
Post by: HaxXxoR on September 20, 2006, 04:01:55 PM
**Bump
Title: Re: SMF Gallery Block
Post by: G6Cad on September 20, 2006, 04:29:47 PM
I think there is a snippet in the Block Code and Snippets board for this.
Look in the sticky post there where thy are sorted for easy find
Title: Re: SMF Gallery Block
Post by: JPDeni on September 20, 2006, 04:45:22 PM
It shouldn't be too hard, depending on how the database is set up. How is the database set up? :)

Title: Re: SMF Gallery Block
Post by: alan s on September 20, 2006, 04:50:30 PM
Well this is the database install code if its any help
//Install the Database tables for SMF Gallery


//Picture Table
db_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}gallery_pic`(
`ID_PICTURE` int(11) NOT NULL auto_increment,
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
`date` int(10) unsigned NOT NULL default '0',
`title` VARCHAR(100) NOT NULL,
`description` text,
`views` int(10) NOT NULL default '0',
`filesize` int(10) NOT NULL default '0',
`height` int(10) NOT NULL default '0',
`width` int(10) NOT NULL default '0',
`filename` tinytext,
`thumbfilename` tinytext,
`commenttotal` int(10) NOT NULL default '0',
`ID_CAT` int(10) NOT NULL default '0',
`approved` tinyint(4) NOT NULL default '0',
`allowcomments` tinyint(4) NOT NULL default '0',
`keywords` VARCHAR(100) NOT NULL,
PRIMARY KEY  (`ID_PICTURE`))", __FILE__, __LINE__);


//Picture comments
db_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}gallery_comment`(
`ID_COMMENT` int(11) NOT NULL auto_increment,
`ID_PICTURE` int(11) NOT NULL,
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
`approved` tinyint(4) NOT NULL default '0',
`comment` text,
`date` int(10) unsigned NOT NULL default '0',
PRIMARY KEY  (`ID_COMMENT`))", __FILE__, __LINE__);

//Gallery Category
db_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}gallery_cat`
(`ID_CAT` mediumint(8) NOT NULL auto_increment,
`title` VARCHAR(100) NOT NULL,
`description` VARCHAR(255) NOT NULL,
`roworder` mediumint(8) unsigned NOT NULL default '0',
`image` VARCHAR(255) NOT NULL,
PRIMARY KEY  (`ID_CAT`))", __FILE__, __LINE__);


//Gallery Reported Images
db_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}gallery_report`
(`ID` int(11) NOT NULL auto_increment,
`ID_PICTURE` int(11) NOT NULL,
`ID_MEMBER` mediumint(8) unsigned NOT NULL default '0',
`comment` text,
`date` int(10) unsigned NOT NULL default '0',
PRIMARY KEY  (`ID`))", __FILE__, __LINE__);

//Insert the settings
db_query("REPLACE INTO {$db_prefix}settings VALUES ('gallery_max_height', '2500')", __FILE__, __LINE__);
db_query("REPLACE INTO {$db_prefix}settings VALUES ('gallery_max_width', '2500')", __FILE__, __LINE__);
db_query("REPLACE INTO {$db_prefix}settings VALUES ('gallery_max_filesize', '5000000')", __FILE__, __LINE__);
?>


And the images are saved into the forumdir/gallery
Title: Re: SMF Gallery Block
Post by: JPDeni on September 20, 2006, 05:02:03 PM
Okay. Latest one.

  $query = db_query(
        "SELECT *  FROM `{$db_prefix}gallery_pic`
         WHERE approved = '1'
         ORDER BY Date DESC
         LIMIT 1", __FILE__, __LINE__);
$latest_pic = mysql_fetch_assoc($query);


That would put the record for the most recently added (and approved) image into an array called $latest_pic and you would use the info from there. So the file name would be in

$latest_pic['filename']

Use the info from the record to display the image, display all the info, create a link to the gallery or whatever you want to do with it.
Title: Re: SMF Gallery Block
Post by: G6Cad on September 20, 2006, 05:50:05 PM
SMF have a gallery mod called SMF Gallery ;)
Just like the Arcade mod is called SMF Arcade :D
Title: Re: SMF Gallery Block
Post by: HaxXxoR on September 20, 2006, 06:18:50 PM
I just want a block that shows the latest image. Doesnt matter what cat its in just show it on the front page. :P
Title: Re: SMF Gallery Block
Post by: JPDeni on September 20, 2006, 08:17:10 PM
The code I posted will give you the information you need to show the latest image. The categories aren't a factor. The only thing I did was to make sure that it had been approved, but you can take that out if you don't care about approval.

I can't really go any further with the code for a couple of reasons. One is that I don't know where your images are located, as compared to your front page, directory-wise. I guess you can fill it in.

  $query = db_query(
        "SELECT *  FROM `{$db_prefix}gallery_pic`
         WHERE approved = '1'
         ORDER BY Date DESC
         LIMIT 1", __FILE__, __LINE__);
$latest_pic = mysql_fetch_assoc($query);

echo '<img src="url/to/image/directory/" . $latest_pic['filename'] . 'height="' $latest_pic['height'] . ' width="' . $latest_pic['width'] '">';


All of the information is there. Just pick what you want and print it out.
Title: Re: SMF Gallery Block
Post by: HaxXxoR on September 20, 2006, 09:05:32 PM
I tried putting that into a php block and change it to my dir and got the following error.

Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in /home/tasty2/public_html/forum/Sources/Load.php(1613) : eval()'d code(34) : eval()'d code on line 8

Any ideas?
Title: Re: SMF Gallery Block
Post by: JPDeni on September 20, 2006, 09:27:49 PM
Looks like I missed a single quote. Let's try again.

$query = db_query(
        "SELECT *  FROM `{$db_prefix}gallery_pic`
         WHERE approved = '1'
         ORDER BY Date DESC
         LIMIT 1", __FILE__, __LINE__);
$latest_pic = mysql_fetch_assoc($query);

echo '<img src="url/to/image/directory/"' . $latest_pic['filename'] . 'height="' $latest_pic['height'] . ' width="' . $latest_pic['width'] '">';
Title: Re: SMF Gallery Block
Post by: Thurnok on September 20, 2006, 09:42:33 PM
more than one ;)

Plus, don't forget the global statement:

global $db_prefix;
$query = db_query(
"SELECT * FROM `{$db_prefix}gallery_pic`
WHERE approved = '1'
ORDER BY Date DESC
LIMIT 1", __FILE__, __LINE__);
$latest_pic = mysql_fetch_assoc($query);

echo '<img src="url/to/image/directory/"' . $latest_pic['filename'] . ' height="' . $latest_pic['height'] . ' width="' . $latest_pic['width'] . '">';
Title: Re: SMF Gallery Block
Post by: JPDeni on September 20, 2006, 10:14:02 PM
I should know better than to try to write code in these little boxes. Thanks, Thurnok.
Title: Re: SMF Gallery Block
Post by: HaxXxoR on September 20, 2006, 10:50:12 PM
This is what i put in and nothing happened.

global $db_prefix;
$query = db_query(
"SELECT * FROM `{$db_prefix}gallery_pic`
WHERE approved = '1'
ORDER BY Date DESC
LIMIT 1", __FILE__, __LINE__);
$latest_pic = mysql_fetch_assoc($query);

echo '<img src="http://www.Tasty-Fragism.com/forum/gallery/"' . $latest_pic['filename'] . ' height="' . $latest_pic['height'] . ' width="' . $latest_pic['width'] . '">';
Title: Re: SMF Gallery Block
Post by: JPDeni on September 20, 2006, 11:38:55 PM
The trouble is that I can't test it because I don't have it installed. I normally don't post code that I haven't tested on my own site and I've got all sorts of little things that I do to troubleshoot when it doesn't work as I expect it to.

First, look at the source code for the page and see what is printed in the block. That should tell us a whole lot.
Title: Re: SMF Gallery Block
Post by: G6Cad on September 23, 2006, 01:35:50 PM
As all mods we have to ask you to search the mod author for help with issues regarding the mods they build.
Title: Re: SMF Gallery Block
Post by: Thurnok on September 23, 2006, 11:53:54 PM
@historyhunter - vbgamer45 has made about 6 updates just in the past week to SMF Gallery.  Might want to check back for a newer version to see if it is fixed.  It is certainly not bug free, but it is looking pretty good so far.  I'm sure in the next few weeks there will be a fairly stable version of it.
Title: Re: SMF Gallery Block
Post by: exerciseforum on October 14, 2006, 08:02:26 PM
hmmm I cant get it work :( has any body got this working on there site?
Title: Re: SMF Gallery Block
Post by: JDMhustle on October 14, 2006, 08:30:28 PM
Yep... just for a limited time, i'm still working on the gallery ;)

http://forum.sirfanaticsholland.com/index.php
Title: Re: SMF Gallery Block
Post by: exerciseforum on October 14, 2006, 09:41:15 PM
Ye thats excellent  :up: now cud i see the box code ? and what bits you edited to your setup..

Thanks alot be great to have it on my site too  :laugh:
Title: Re: SMF Gallery Block
Post by: JDMhustle on October 14, 2006, 10:12:00 PM
well i used the SSI Mod for SMF Gallery

Includes the following functions
ssi_gallerylatestpicture($output_method = 'echo');
ssi_gallerystats($output_method = 'echo');
ssi_galleryrandom();

Then put it in a php block and presto ;)
Do you have the lite or Pro version?
Title: Re: SMF Gallery Block
Post by: Jpg on October 14, 2006, 10:21:06 PM
Here comes JPG to save the day!
echo'
<table cellspacing="0" cellpadding="2" border="0px black solid" align="center" width="90%"><tr>';
  if(empty($modSettings['gallery_url']))
  {
    $modSettings['gallery_url'] = $boardurl . '/gallery/';
  }
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY date DESC LIMIT 5", __FILE__,__LINE__);
  while ($row = mysql_fetch_assoc($request))
  echo' <center><td align="center" colspan="3"><a href="', $scripturl, '?action=gallery;sa=view;id=',
  $row['ID_PICTURE'], '"><img src="',  $modSettings['gallery_url'] .

  $row['thumbfilename'] ,'" /></a></center>';
  echo'</td></tr>';
  echo'</table></br>';
  mysql_free_result($request);

I use it at mine. Http://inflamehq.com
User:Demo
Pass:Demo

Might want to check out my topic for modding your whole template for the gallery at SMF hacks.
http://www.smfhacks.com/index.php/topic,188.msg1231/topicseen.html#new

Title: Re: SMF Gallery Block
Post by: exerciseforum on October 14, 2006, 10:42:08 PM
I have the lite version...
I must be missing something

anybody got a step by step lol i need it ...
Title: Re: SMF Gallery Block
Post by: Jpg on October 14, 2006, 10:50:13 PM
I too have the Lite Version.
You need to add
echo'
<table cellspacing="0" cellpadding="2" border="0px black solid" align="center" width="90%"><tr>';
  if(empty($modSettings['gallery_url']))
  {
    $modSettings['gallery_url'] = $boardurl . '/gallery/';
  }
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY date DESC LIMIT 5", __FILE__,__LINE__);
  while ($row = mysql_fetch_assoc($request))
  echo' <center><td align="center" colspan="3"><a href="', $scripturl, '?action=gallery;sa=view;id=',
  $row['ID_PICTURE'], '"><img src="',  $modSettings['gallery_url'] .

  $row['thumbfilename'] ,'" /></a></center>';
  echo'</td></tr>';
  echo'</table></br>';
  mysql_free_result($request);


In a php block.
If you want less than 5 images appearing change the Limit Number
LIMIT 5
to something less than 5 or more than 5. :D
Title: Re: SMF Gallery Block
Post by: exerciseforum on October 14, 2006, 11:06:47 PM
well i get this error when i do that

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

:-\
Title: Re: SMF Gallery Block
Post by: Jpg on October 14, 2006, 11:17:03 PM
It's not the code then it's your forum.
Title: Re: SMF Gallery Block
Post by: exerciseforum on October 14, 2006, 11:22:14 PM
oh poo :( thanks for ur help anyways
Title: Re: SMF Gallery Block
Post by: Jpg on October 15, 2006, 05:03:24 AM
Wait...lol...hahahaha..I forgot something in my code....

global $scripturl,$db_prefix,$modSettings,$boardurl;
  echo'<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%"><tr>';
  if(empty($modSettings['gallery_url']))
  {
    $modSettings['gallery_url'] = $boardurl . '/gallery/';
  }
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY date DESC LIMIT 3", __FILE__,__LINE__);
  while ($row = mysql_fetch_assoc($request))
  echo' <center><td align="center" colspan="3"><a href="', $scripturl, '?action=gallery;sa=view;id=',
  $row['ID_PICTURE'], '"><img src="',  $modSettings['gallery_url'] .

  $row['thumbfilename'] ,'" /></a></center>';
  echo'</td></tr>';
  echo'</table></br>';
  mysql_free_result($request);
Title: Re: SMF Gallery Block
Post by: exerciseforum on October 15, 2006, 01:51:21 PM
IT WORKS! thanks Jpg! :D
Title: Re: SMF Gallery Block
Post by: Jpg on October 15, 2006, 05:33:37 PM
Your welcome. I forgot the global commands....lol...
Title: Re: SMF Gallery Block
Post by: bluedevil on October 16, 2006, 01:19:07 AM
Sweet mod. It worked fine without complications. Changed the number of pics to display to 1. :up:

Thnx guys!                 BD.
Title: Re: SMF Gallery Block
Post by: bluedevil on October 16, 2006, 10:29:04 PM
Ok...now im getting more creative. I switched the limit to 4. Is it possibble to make it scroll from right to left?
Title: Re: SMF Gallery Block
Post by: houston on October 17, 2006, 04:33:33 AM
This mod seems to move all the contents of the block below it to the right, Has anybody else had this bug.
Title: Re: SMF Gallery Block
Post by: bluedevil on October 17, 2006, 05:24:26 AM
Quote from: houston on October 17, 2006, 04:33:33 AM
This mod seems to move all the contents of the block below it to the right, Has anybody else had this bug.

i had it on a right block with a limit of 1.It worked just fine.  Later changed to a center block with a limit of 4. No problems there either. Im guessing if you have a high limit it will leave the assigned area. But i may be wrong.
Title: Re: SMF Gallery Block
Post by: ScoobyDan on October 27, 2006, 01:34:49 PM
Hi,

Would it be possible to also add the title of the image, just below the image?

This script is great, and I think that having the title of the image (which could be turned off by commenting out the respective lines) would be the finishing touch.

Many thanks,

Daniel
Title: Re: SMF Gallery Block
Post by: HappyFace on October 28, 2006, 12:30:00 PM
A question for JPG, it is possible to cahnge it so that a random pic will be displayed?
Title: Re: SMF Gallery Block
Post by: ScoobyDan on October 28, 2006, 01:49:50 PM
HappyFace,

I can answer that one :D

Change the line:
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY date DESC LIMIT 3", __FILE__,__LINE__);

to:
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY rand() DESC LIMIT 3", __FILE__,__LINE__);

i.e. change the "date" to "rand()".

You might also want to change the "LIMIT 3" to "LIMIT 1", to only show one picture.

Daniel
Title: Re: SMF Gallery Block
Post by: HappyFace on October 28, 2006, 02:31:13 PM
Quote from: ScoobyDan on October 28, 2006, 01:49:50 PM
HappyFace,

I can answer that one :D

Change the line:
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY date DESC LIMIT 3", __FILE__,__LINE__);

to:
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY rand() DESC LIMIT 3", __FILE__,__LINE__);

i.e. change the "date" to "rand()".

You might also want to change the "LIMIT 3" to "LIMIT 1", to only show one picture.

Daniel

Wow, thanks for the quick reply!

Do you also know how I can make the images appear below eachother?
Thanks.
Title: Re: SMF Gallery Block
Post by: D@ve on November 17, 2006, 09:38:02 AM
Quote from: houston on October 17, 2006, 04:33:33 AM
This mod seems to move all the contents of the block below it to the right, Has anybody else had this bug.

I also had that happen to me Houston. had to remove a 2 things. heres the code i used to fix
global $scripturl,$db_prefix,$modSettings,$boardurl;
  echo'<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%"><tr>';
  if(empty($modSettings['gallery_url']))
  {
    $modSettings['gallery_url'] = $boardurl . '/gallery/';
  }
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY

date DESC LIMIT 1", __FILE__,__LINE__);
  while ($row = mysql_fetch_assoc($request))
  echo' <td align="center" colspan="3"><a href="', $scripturl, '?action=gallery;sa=view;id=',
  $row['ID_PICTURE'], '"><img src="',  $modSettings['gallery_url'] .

  $row['thumbfilename'] ,'" /></a>';
  echo'</td></tr>';
  echo'</table></br>';
  mysql_free_result($request);
Title: Re: SMF Gallery Block
Post by: TheWrks on December 13, 2006, 03:39:52 AM
It works for me  :up: Thanks to all that helped  ;D

Random Photo

http://www.michiganmini.org/forum/ (http://www.michiganmini.org/forum/)
Title: Re: SMF Gallery Block
Post by: Thurnok on December 13, 2006, 06:12:16 AM
If you are looking for a random pic, latest, oldest, most/least viewed, most/least commented, pics from members on your buddy list, or pics from a specific member in their profile block then  try this block (http://www.tinyportal.net/index.php?topic=10971.0).
Title: Re: SMF Gallery Block
Post by: Slack on March 13, 2007, 03:21:00 AM
Hahaha old thread but sweet snippet.

http://exposingmusic.net/index.php?action=gallery (http://exposingmusic.net/index.php?action=gallery)
Title: Re: SMF Gallery Block
Post by: kopijun on May 13, 2007, 04:00:24 PM
QuoteWait...lol...hahahaha..I forgot something in my code....

global $scripturl,$db_prefix,$modSettings,$boardurl;
  echo'<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%"><tr>';
  if(empty($modSettings['gallery_url']))
  {
    $modSettings['gallery_url'] = $boardurl . '/gallery/';
  }
  $request = db_query("SELECT thumbfilename,ID_PICTURE FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY date DESC LIMIT 3", __FILE__,__LINE__);
  while ($row = mysql_fetch_assoc($request))
  echo' <center><td align="center" colspan="3"><a href="', $scripturl, '?action=gallery;sa=view;id=',
  $row['ID_PICTURE'], '"><img src="',  $modSettings['gallery_url'] .

  $row['thumbfilename'] ,'" /></a></center>';
  echo'</td></tr>';
  echo'</table></br>';
  mysql_free_result($request);

It's very nice, I just used in my sites...But Is it possible to make this block showed only on the 1st page ? I mean, when I look article category, this gallery block is always there....Could anyone tell me what to do ? Thanks in advance..
Title: Re: SMF Gallery Block
Post by: Freddy on November 30, 2007, 07:23:24 PM
Here's a slight modifcation that will scroll any number of random images from SMF gallery and also generate roll over texts for each image.

Alter scrollamount and scrolldelay to change the scrolling speed.

You might want to alter the marquee width to fit wherever you are using it.

Change the RAND() LIMIT value to alter the number of images it displays, or tailor that bit to suit your needs.

global $scripturl, $db_prefix, $modSettings, $boardurl;

echo '<div align="center"><marquee scrollamount="1" scrolldelay="20" direction="left" loop="true" width="50%" onmouseover=\'this.stop()\'onmouseout=\'this.start()\'>';

if(empty($modSettings['gallery_url']))
{
     $modSettings['gallery_url'] = $boardurl . '/gallery/';
}

$request = db_query("SELECT thumbfilename, ID_PICTURE, title, ID_MEMBER FROM {$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY RAND() LIMIT 20" , __FILE__,__LINE__);

while ($row = mysql_fetch_assoc($request))
{
     $request_name = db_query("SELECT memberName FROM {$db_prefix}members WHERE ID_MEMBER LIKE '{$row['ID_MEMBER']}'", __FILE__, __LINE__);
     $row_name = mysql_fetch_assoc($request_name);

     $alt_text = $row['title'] . " by " . $row_name['memberName'];

     echo ' <a href="', $scripturl, '?action=gallery;sa=view;id=', $row['ID_PICTURE'], '"><img alt="' , $alt_text , '" src="',  $modSettings['gallery_url'] . $row['thumbfilename'] ,'" /></a>';

     mysql_free_result($request_name);
}
     
echo '</marquee></div>';

mysql_free_result($request);


Here's how I am using it : http://aidreams.co.uk/forum/index.php?action=gallery
Title: Re: SMF Gallery Block
Post by: forummaker on July 21, 2008, 12:08:38 AM
Finally found a code that works without any errors. Thanks!
Title: Re: SMF Gallery Block
Post by: NenaGb on December 17, 2008, 08:12:39 AM
I second this ...although this thread is outdated THANK YOU SO MUCH FOR THE CODE and the fixes