Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

August 19, 2022, 06:14:47 AM

Login with username, password and session length
Members
  • Total Members: 3843
  • Latest: Tricky
Stats
  • Total Posts: 193479
  • Total Topics: 21088
  • Online today: 58
  • Online ever: 1035
  • (November 26, 2020, 04:45:12 AM)
Users Online
Users: 1
Guests: 48
Total: 49

Author Topic: SMF Gallery Block  (Read 27607 times)

0 Members and 1 Guest are viewing this topic.

HaxXxoR

  • Guest
SMF Gallery Block
« on: September 19, 2006, 11:50:04 AM »
Does anyone know how to make a Block that will show the latest image for SMF Gallery???

HaxXxoR

  • Guest
Re: SMF Gallery Block
« Reply #1 on: September 20, 2006, 09:01:55 AM »
**Bump

Offline G6Cad

  • Friends
  • *
  • Posts: 12643
    • FamiljeGodis
Re: SMF Gallery Block
« Reply #2 on: September 20, 2006, 09:29:47 AM »
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

  • Guest
Re: SMF Gallery Block
« Reply #3 on: September 20, 2006, 09:45:22 AM »
It shouldn't be too hard, depending on how the database is set up. How is the database set up? :)


alan s

  • Guest
Re: SMF Gallery Block
« Reply #4 on: September 20, 2006, 09:50:30 AM »
Well this is the database install code if its any help
Code: [Select]
//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

  • Guest
Re: SMF Gallery Block
« Reply #5 on: September 20, 2006, 10:02:03 AM »
Okay. Latest one.

Code: [Select]
  $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.
« Last Edit: September 20, 2006, 01:17:46 PM by JPDeni »

Offline G6Cad

  • Friends
  • *
  • Posts: 12643
    • FamiljeGodis
Re: SMF Gallery Block
« Reply #6 on: September 20, 2006, 10:50:05 AM »
SMF have a gallery mod called SMF Gallery ;)
Just like the Arcade mod is called SMF Arcade :D

HaxXxoR

  • Guest
Re: SMF Gallery Block
« Reply #7 on: September 20, 2006, 11:18:50 AM »
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

  • Guest
Re: SMF Gallery Block
« Reply #8 on: September 20, 2006, 01: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.

Code: [Select]
  $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

  • Guest
Re: SMF Gallery Block
« Reply #9 on: September 20, 2006, 02: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?