Does anyone know how to make a Block that will show the latest image for SMF Gallery???
**Bump
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
It shouldn't be too hard, depending on how the database is set up. How is the database set up? :)
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
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.
SMF have a gallery mod called SMF Gallery ;)
Just like the Arcade mod is called SMF Arcade :D
I just want a block that shows the latest image. Doesnt matter what cat its in just show it on the front page. :P
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.
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?
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'] '">';
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'] . '">';
I should know better than to try to write code in these little boxes. Thanks, Thurnok.
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'] . '">';
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.
As all mods we have to ask you to search the mod author for help with issues regarding the mods they build.
@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.
hmmm I cant get it work :( has any body got this working on there site?
Yep... just for a limited time, i'm still working on the gallery ;)
http://forum.sirfanaticsholland.com/index.php
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:
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?
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
I have the lite version...
I must be missing something
anybody got a step by step lol i need it ...
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
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.
:-\
It's not the code then it's your forum.
oh poo :( thanks for ur help anyways
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);
IT WORKS! thanks Jpg! :D
Your welcome. I forgot the global commands....lol...
Sweet mod. It worked fine without complications. Changed the number of pics to display to 1. :up:
Thnx guys! BD.
Ok...now im getting more creative. I switched the limit to 4. Is it possibble to make it scroll from right to left?
This mod seems to move all the contents of the block below it to the right, Has anybody else had this bug.
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.
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
A question for JPG, it is possible to cahnge it so that a random pic will be displayed?
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
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.
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);
It works for me :up: Thanks to all that helped ;D
Random Photo
http://www.michiganmini.org/forum/ (http://www.michiganmini.org/forum/)
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).
Hahaha old thread but sweet snippet.
http://exposingmusic.net/index.php?action=gallery (http://exposingmusic.net/index.php?action=gallery)
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..
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
Finally found a code that works without any errors. Thanks!
I second this ...although this thread is outdated THANK YOU SO MUCH FOR THE CODE and the fixes