TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

March 29, 2024, 08:21:36 AM

Login with username, password and session length
Members
Stats
  • Total Posts: 195,106
  • Total Topics: 21,213
  • Online today: 358
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 77
  • Total: 77

SMF Gallery Block

Started by HaxXxoR, September 19, 2006, 06:50:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

HaxXxoR

Does anyone know how to make a Block that will show the latest image for SMF Gallery???


G6Cad

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

JPDeni

It shouldn't be too hard, depending on how the database is set up. How is the database set up? :)


alan s

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

JPDeni

#5
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.

G6Cad

SMF have a gallery mod called SMF Gallery ;)
Just like the Arcade mod is called SMF Arcade :D

HaxXxoR

I just want a block that shows the latest image. Doesnt matter what cat its in just show it on the front page. :P

JPDeni

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.

HaxXxoR

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?