TinyPortal

Development => Block Codes => Topic started by: Freddy on April 10, 2010, 03:55:29 PM

Title: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on April 10, 2010, 03:55:29 PM
I decided to start this new topic for us to work with this update as the old topic was for SMF 1.

So, here is an updated version of this block by Thurnok (http://www.tinyportal.net/index.php?topic=10971.0)...

The new converted code has a new home which can be found here... (http://www.tinyportal.net/index.php?topic=32492.0)

So far I have weeded out the old variables, database names etc and at the moment have used TP's database functions, with a view to later using the 'new' SMF 2 database functions.

Test it please and try to break it  :o  When we have done that I will add the block to the new block code area.

////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.8          //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 9/26/2008
// 1.8
// - added display # of comments option
//
// Updated 10 April 2010 by Freddy888 to work with SMF2
//
// Used in a TinyPortal phpblock or Article.
// This block displays random/most/least/newest/oldest picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

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

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 1;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 0;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 1;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 1;
// display membername who posted pic?
$gal_dispMember = 1;
// display posted date?
$gal_dispDate = 1;
// display category the picture is in?
$gal_dispCategory = 1;
// display number of views?
$gal_dispViews = 1;
// display dimensions?
$gal_dispDimensions = 1;
// display filesize?
$gal_dispSize = 1;
// display picture description?
$gal_dispDescription = 0;
// display # comments
$gal_dispNumComments = 0;

//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = "4,2,7" - don't show categories 2, 4, or 7
$gal_disallowCats = "";
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

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

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
$gal_showtype = 0;

// sort text
if (empty($gal_sort)){
$gal_sort_text = 'DESC';
} else {
$gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile"){
$gal_member = empty($_GET['u']) ? $context['user']['id'] : $_GET['u'];
}
// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view')){
$gal_query = '
SELECT
thumbfilename,
id_picture,
id_member,
date,
title,
description,
views,
filesize,
height,
width,
commenttotal,
id_cat
FROM '.$db_prefix.'gallery_pic
WHERE approved = 1
'.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "AND id_member = NULL " : "AND id_member in ($gal_buddylist)")) : "AND id_member = $gal_member" ).'
'.(empty($gal_disallowCats) ? "" : " AND id_cat NOT IN ($gal_disallowCats)").'
'.(empty($gal_allowCats) ? "" : " AND id_cat IN ($gal_allowCats)").'
GROUP BY thumbfilename ';

switch ($gal_showtype){
// most/least recent
case 1:
$gal_query .= '
ORDER BY date '.$gal_sort_text;
break;

// most/least viewed
case 2:
$gal_query .= '
ORDER BY views '.$gal_sort_text;
break;

// most/least commented
case 3:
$gal_query .= '
ORDER BY commenttotal '.$gal_sort_text;
break;

default:
$gal_query .= '
ORDER BY rand() '.$gal_sort_text;
break;
}
$gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';
$gal_result = tp_query($gal_query, __FILE__, __LINE__);
if (!$gal_result){
// error retrieving information from database
if (mysql_errno() == 1146){
echo '<p />Error, no database found!<p />';
} else {
echo '<p />MySQL error:'.mysql_error().'<p />';
}
} else {
echo "\n".'<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%">'."\n";

$gal_colcnt = 1;
echo " <tr>\n";

while ($row = tpdb_fetch_assoc($gal_result)){
if ($gal_colcnt > $gal_columns){
// close out the row and start a new row
echo " </tr>\n <tr>\n".' <td colspan="'.$gal_columns.'"><hr /></td>'."\n </tr>\n <tr>\n";
// reset count to column 1
$gal_colcnt = 1;
}
echo ' <td class="'.$gal_textclass.'" align="center">'."\n";
// display title if enabled, make edit link if viewing user is picture poster
if (!empty($gal_dispTitle)){
echo " ".($context['user']['id'] == $row['id_member'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;pic='.$row['id_picture'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
}
// display the picture thumbnail and link it to gallery full picture
echo ' <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'" /></a><br />'."\n";
// display poster's name and posted date if enabled
if (!empty($gal_dispMember) || !empty($gal_dispDate)){
echo 'Posted';
if (!empty($gal_dispMember)){
// display the member name who posted pic?  need to get name based on id_member
$get_name_result = tp_query("SELECT member_name FROM ".$db_prefix."members WHERE id_member = ".$row['id_member'], __FILE__, __LINE__);
$gal_tmp = tpdb_fetch_assoc($get_name_result);
echo ' by <a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$gal_tmp['member_name'].'</a>';
}
if (!empty($gal_dispDate)){
// display the date it was posted
echo ' on '.date("d M Y", $row['date']);
}
echo "<br />\n";
}
// display category if enabled
if (!empty($gal_dispCategory)){
// get category name based on category id
$get_category_result = tp_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE id_cat = ".$row['id_cat'], __FILE__, __LINE__);
$gal_tmp = tpdb_fetch_assoc($get_category_result);

echo '<br />in<br /><a href="'.$scripturl.'?action=gallery;cat='.$row['id_cat'].'">'.$gal_tmp['title']."</a><br /><br />\n";
}
// display number of views if enabled
if (!empty($gal_dispViews)){
echo "Viewed ".$row['views']." times<br />\n";
}
// display dimensions if enabled
if (!empty($gal_dispDimensions)){
echo $row['width']."w X ".$row['height']."h<br />\n";
}
// display filesize if enabled
if (!empty($gal_dispSize)){
echo $row['filesize']." bytes<br />\n";
}
// display description if enabled
if (!empty($gal_dispDescription)){
echo "<br />".$row['description']."<br />\n";
}
// display # of comments if enabled
if (!empty($gal_dispNumComments)){
echo '<br /><i><a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'">'.$row['commenttotal']."</a> comment(s)</i><br />\n";
}
echo " </td>\n";
$gal_colcnt++;
}

mysql_free_result($gal_result);

echo " </tr>\n</table>\n";
if (!empty($gal_member) && empty($_GET['gal_viewall']))
echo '<br /><a href="'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';
if (!empty($gal_buddies) && empty($_GET['gal_viewall'])){
// build the link
$gal_querystring = $context['TPortal']['querystring'];
$gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
echo '<br /><a href="'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
}
}
} else {
echo 'Sorry, you do not have permission to view pictures!';
}
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Blue Steel on April 10, 2010, 04:05:01 PM
what did you actually have to change ?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on April 10, 2010, 04:16:56 PM
I added it to a PHP article since its the only way i can preview it before putting it to the forums like blocks does.

I got an error to start,

Parse error: syntax error, unexpected T_VARIABLE in /home/*******/public_html/Sources/TPSubs.php(1730) : eval()'d code on line 101
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on April 10, 2010, 04:19:53 PM
Nevermind.....

It must be the TP version im using TPb5.

Seems to be working in PHP blocks..... let me try and break it.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on April 10, 2010, 04:21:03 PM
Quote from: BlueSteel on April 10, 2010, 04:05:01 PM
what did you actually have to change ?

I had to change the database functions, some of the variables and some of the database field names.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on April 10, 2010, 04:21:47 PM
Quote from: bluedevil on April 10, 2010, 04:19:53 PM
Nevermind.....

It must be the TP version im using TPb5.

Seems to be working in PHP blocks..... let me try and break it.
I'm using the latest revision of TP with RC3 and it's working in blocks and articles.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Blue Steel on April 10, 2010, 04:25:55 PM
ahhh ok.. ;) thanks .. I'll update my block in case i go back to using gallery .. I keep all blocks i ever write or use ;) as inactive.. for quick reference ;)

BTW the prob is known in TP 1.0 Beta5 with SMF 2.0 RC3 articles .. I have the same problem. Blocks work fine though

it doesn't like delving into {

}


they's stated that its fixed in the next release due soon
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on April 10, 2010, 04:31:30 PM
Yeah, freddy, im still using the public release not the updated one yet.  Thats why is not working for me for articles.


But,..... you are a genius.... i couldnt break it.  It follows permissions like it suppose to and all commands from the code settings.


See it in action, top block; http://www.chevyavalancheclub.com/index.php
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Crip on April 10, 2010, 04:39:47 PM
Quote from: BlueSteel on April 10, 2010, 04:05:01 PM
what did you actually have to change ?

You could look at the changes made in the RC3 updated php-code Block: ['mini-calendar'] , most blockcode's / snippets need Updating..
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on April 10, 2010, 04:52:30 PM
Quote from: bluedevil on April 10, 2010, 04:31:30 PM
Yeah, freddy, im still using the public release not the updated one yet.  Thats why is not working for me for articles.


But,..... you are a genius.... i couldnt break it.  It follows permissions like it suppose to and all commands from the code settings.


See it in action, top block; http://www.chevyavalancheclub.com/index.php

Thanks but most of the work was already done, I just needed to update specific parts for it to work with SMF 2, the rest is down to Thurnock.

Glad it works though :)

That's my first try at updating a block for SMF 2 and it wasn't too painful lol

I'll come back to this later and update it to using the SMF database functions as I think Bloc aims to use that method in future.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on April 10, 2010, 04:53:27 PM
Quote from: BlueSteel on April 10, 2010, 04:25:55 PM
ahhh ok.. ;) thanks .. I'll update my block in case i go back to using gallery .. I keep all blocks i ever write or use ;) as inactive.. for quick reference ;)

BTW the prob is known in TP 1.0 Beta5 with SMF 2.0 RC3 articles .. I have the same problem. Blocks work fine though

it doesn't like delving into {

}


they's stated that its fixed in the next release due soon


Yeah that error looked familiar.  Good idea on keeping the blocks. :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on April 11, 2010, 02:41:05 PM
Freddy,   i just updated TP to the latest public release tpb1.

The code worked before until today's update.

Now i get:
Parse error: syntax error, unexpected T_VARIABLE in /home/******/public_html/Sources/TPSubs.php(1720) : eval()'d code on line 101

Do you get same error?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Blue Steel on April 11, 2010, 02:45:09 PM
did you read this ??? that i posted after i upgraded ??

http://www.tinyportal.net/index.php?topic=32367.msg260099#msg260099
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on April 11, 2010, 02:47:00 PM
Quote from: BlueSteel on April 11, 2010, 02:45:09 PM
did you read this ??? that i posted after i upgraded ??

http://www.tinyportal.net/index.php?topic=32367.msg260099#msg260099
No i didnt, thanx.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Ken. on April 18, 2010, 07:11:51 PM
Works good.  O0


Bottom of page:
http://www.ourfamilyforum.org/FamilyForum/index.php?action=forum
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on April 18, 2010, 07:15:17 PM
Cool  8)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: rockyrails on May 16, 2010, 01:43:15 AM
This is a popular mod on my forum too - the members love it

see :   http://7-8ths.info (http://7-8ths.info)

Using smf2RC3 and TP1 beta5.1
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: ZarPrime on May 16, 2010, 03:56:15 AM
rockyrails,

I think that's the first time I've seen your site.  It looks great and you have done an excellent job on it. O0

ZarPrime
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on May 16, 2010, 12:50:28 PM
Yes great looking site  8)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: rockyrails on May 16, 2010, 04:57:42 PM
Thanks - would not have been possible for me without the help of this forum and TP.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: kefolds on June 25, 2010, 05:53:34 AM
Could this be used to pull random pictures instead of thumbnails?  I would like to have a random full size picture on my home page.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: kefolds on June 27, 2010, 03:50:47 AM
I know you are very busy with the move but if there is a way to do this please let me know, if not please tell me that so I don't keep waiting.

Thanks
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on June 27, 2010, 02:19:33 PM
Hi there :)

What exactly do you want it to show ?

Just the picture or also the details as shown with the thumbnail ?

How are you going to control the size of the images people upload ?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: kefolds on June 27, 2010, 06:08:57 PM
I would like to be able to pull the actual picture, not the thumbnail. If it is too much trouble I can just change it manually every day. It is on the site I have for my son's Christian rock band  www.chosenrock.com
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on June 27, 2010, 06:10:46 PM
Yep I understand you, but just the picture ?  No details or anything ?

QuoteHow are you going to control the size of the images people upload ?

And what about the image sizes...
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: kefolds on June 27, 2010, 06:14:51 PM
true, no details. size I would have to play with that. Probably a max width of 650
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on June 27, 2010, 06:21:53 PM
Okey dokey.

Try this out then :

////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.8          //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 9/26/2008
// 1.8
// - added display # of comments option
//
// Modified 27 June 2010 by Freddy888 to work with SMF2
// and show full size images.
//
// Used in a TinyPortal phpblock or Article.
// This block displays random/most/least/newest/oldest picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

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

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 1;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 0;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 1;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 0;
// display membername who posted pic?
$gal_dispMember = 0;
// display posted date?
$gal_dispDate = 0;
// display category the picture is in?
$gal_dispCategory = 0;
// display number of views?
$gal_dispViews = 0;
// display dimensions?
$gal_dispDimensions = 0;
// display filesize?
$gal_dispSize = 0;
// display picture description?
$gal_dispDescription = 0;
// display # comments
$gal_dispNumComments = 0;

//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = "4,2,7" - don't show categories 2, 4, or 7
$gal_disallowCats = "";
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

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

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
$gal_showtype = 0;

// sort text
if (empty($gal_sort)){
$gal_sort_text = 'DESC';
} else {
$gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile"){
$gal_member = empty($_GET['u']) ? $context['user']['id'] : $_GET['u'];
}
// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view')){
$gal_query = '
SELECT
filename,
id_picture,
id_member,
date,
title,
description,
views,
filesize,
height,
width,
commenttotal,
id_cat
FROM '.$db_prefix.'gallery_pic
WHERE approved = 1
'.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "AND id_member = NULL " : "AND id_member in ($gal_buddylist)")) : "AND id_member = $gal_member" ).'
'.(empty($gal_disallowCats) ? "" : " AND id_cat NOT IN ($gal_disallowCats)").'
'.(empty($gal_allowCats) ? "" : " AND id_cat IN ($gal_allowCats)").'
GROUP BY thumbfilename ';

switch ($gal_showtype){
// most/least recent
case 1:
$gal_query .= '
ORDER BY date '.$gal_sort_text;
break;

// most/least viewed
case 2:
$gal_query .= '
ORDER BY views '.$gal_sort_text;
break;

// most/least commented
case 3:
$gal_query .= '
ORDER BY commenttotal '.$gal_sort_text;
break;

default:
$gal_query .= '
ORDER BY rand() '.$gal_sort_text;
break;
}
$gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';
$gal_result = tp_query($gal_query, __FILE__, __LINE__);
if (!$gal_result){
// error retrieving information from database
if (mysql_errno() == 1146){
echo '<p />Error, no database found!<p />';
} else {
echo '<p />MySQL error:'.mysql_error().'<p />';
}
} else {
echo "\n".'<table cellspacing="0" cellpadding="5" border="0" align="center" width="90%">'."\n";

$gal_colcnt = 1;
echo " <tr>\n";

while ($row = tpdb_fetch_assoc($gal_result)){
if ($gal_colcnt > $gal_columns){
// close out the row and start a new row
echo " </tr>\n <tr>\n".' <td colspan="'.$gal_columns.'"><hr /></td>'."\n </tr>\n <tr>\n";
// reset count to column 1
$gal_colcnt = 1;
}
echo ' <td class="'.$gal_textclass.'" align="center">'."\n";
// display title if enabled, make edit link if viewing user is picture poster
if (!empty($gal_dispTitle)){
echo " ".($context['user']['id'] == $row['id_member'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;pic='.$row['id_picture'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
}
// display the picture and link it to gallery full picture
echo ' <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['filename'].'" /></a><br />'."\n";
// display poster's name and posted date if enabled
if (!empty($gal_dispMember) || !empty($gal_dispDate)){
echo 'Posted';
if (!empty($gal_dispMember)){
// display the member name who posted pic?  need to get name based on id_member
$get_name_result = tp_query("SELECT member_name FROM ".$db_prefix."members WHERE id_member = ".$row['id_member'], __FILE__, __LINE__);
$gal_tmp = tpdb_fetch_assoc($get_name_result);
echo ' by <a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$gal_tmp['member_name'].'</a>';
}
if (!empty($gal_dispDate)){
// display the date it was posted
echo ' on '.date("d M Y", $row['date']);
}
echo "<br />\n";
}
// display category if enabled
if (!empty($gal_dispCategory)){
// get category name based on category id
$get_category_result = tp_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE id_cat = ".$row['id_cat'], __FILE__, __LINE__);
$gal_tmp = tpdb_fetch_assoc($get_category_result);

echo '<br />in<br /><a href="'.$scripturl.'?action=gallery;cat='.$row['id_cat'].'">'.$gal_tmp['title']."</a><br /><br />\n";
}
// display number of views if enabled
if (!empty($gal_dispViews)){
echo "Viewed ".$row['views']." times<br />\n";
}
// display dimensions if enabled
if (!empty($gal_dispDimensions)){
echo $row['width']."w X ".$row['height']."h<br />\n";
}
// display filesize if enabled
if (!empty($gal_dispSize)){
echo $row['filesize']." bytes<br />\n";
}
// display description if enabled
if (!empty($gal_dispDescription)){
echo "<br />".$row['description']."<br />\n";
}
// display # of comments if enabled
if (!empty($gal_dispNumComments)){
echo '<br /><i><a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'">'.$row['commenttotal']."</a> comment(s)</i><br />\n";
}
echo " </td>\n";
$gal_colcnt++;
}

mysql_free_result($gal_result);

echo " </tr>\n</table>\n";
if (!empty($gal_member) && empty($_GET['gal_viewall']))
echo '<br /><a href="'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';
if (!empty($gal_buddies) && empty($_GET['gal_viewall'])){
// build the link
$gal_querystring = $context['TPortal']['querystring'];
$gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
echo '<br /><a href="'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
}
}
} else {
echo 'Sorry, you do not have permission to view pictures!';
}
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: kefolds on June 28, 2010, 12:30:11 AM
Thanks. it seems to be working great. A little slow to load but that is to be expected (only about 1.5 seconds)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on June 28, 2010, 02:49:51 PM
Yep bigger pictures equals longer load times.  Glad it's working out though :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Chinaren on July 03, 2010, 09:58:06 AM
It's only been minutes, but initial impressions are that this works fine on my RC3 board.  Thanks for your work!
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on July 03, 2010, 12:40:31 PM
Welcome :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: kefolds on July 05, 2010, 03:47:44 PM
I have had a problem reported to me. If it is viewed in less than 1152x864 the picture overlaps the right side blocks.
I have tried setting the forced width of the block and tried changing the code for the table width, any suggestions?

Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on July 05, 2010, 03:54:29 PM
Yes, I said image sizes could pose a problem with this if you read back a bit.

Two solutions :

1) Limit the size of images that people upload.

2) Force the browser to resize the full size image on the fly by editing the code :

Find this :

// display the picture thumbnail and link it to gallery full picture
echo ' <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['filename'].'" /></a><br />'."\n";


Replace it with something like this :

// display the picture and link it to gallery full picture
echo ' <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['filename'].'" width="650" /></a><br />'."\n";


Just change the width="650" to whatever width you want to rescale it to.  It should rescale height automatically I think.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: kefolds on July 05, 2010, 04:10:38 PM
Your good. It worked . Thanks
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on July 05, 2010, 04:15:26 PM
Welcome  :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Balou on June 05, 2011, 02:54:39 PM
Sorry but do not understand, where do I paste this code?

Could this hack help me with this, want to show the latest or random pictures on forum home/first page under the menubar?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: ZarPrime on June 05, 2011, 05:04:43 PM
Balou,

Welcome to TinyPortal.net.

This code should be able to be used in either a php article or a php block.

Freddy should be able to answer your second question as soon as he sees this.

ZarPrime
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on June 05, 2011, 06:18:24 PM
I suggest you go back and read the thread and also follow the link to Thurnock's original code.  Then you will be able to decide if it will be useful to you.

I only converted the code, and that was a year back now.  So I forget what it does, if ever I knew, but you are the ideal person to look into it as you are the one who will be using it.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on July 10, 2011, 03:09:04 PM
Ive been using this block code since for ever in 2.0 series. Since i updated to 2.0 gold, it no longer works.

It breaks the forum. Something to do with tp_query()

////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.8          //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 9/26/2008
// 1.8
//      - added display # of comments option
//
// Updated 10 April 2010 by Freddy888 to work with SMF2
//
// Used in a TinyPortal phpblock or Article.
// This block displays random/most/least/newest/oldest picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

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

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 7;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 1;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 7;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 0;
// display membername who posted pic?
$gal_dispMember = 1;
// display posted date?
$gal_dispDate = 0;
// display category the picture is in?
$gal_dispCategory = 0;
// display number of views?
$gal_dispViews = 0;
// display dimensions?
$gal_dispDimensions = 0;
// display filesize?
$gal_dispSize = 0;
// display picture description?
$gal_dispDescription = 0;
// display # comments
$gal_dispNumComments = 0;

//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = "4,2,7" - don't show categories 2, 4, or 7
$gal_disallowCats = "3,4,13,15,16,17,155,172,175";
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

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

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
   $gal_showtype = 0;

// sort text
if (empty($gal_sort)){
   $gal_sort_text = 'DESC';
} else {
   $gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile"){
   $gal_member = empty($_GET['u']) ? $context['user']['id'] : $_GET['u'];
}
// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view')){
   $gal_query = '
         SELECT
            thumbfilename,
            id_picture,
            id_member,
            date,
            title,
            description,
            views,
            filesize,
            height,
            width,
            commenttotal,
            id_cat
         FROM '.$db_prefix.'gallery_pic
         WHERE approved = 1
         '.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "AND id_member = NULL " : "AND id_member in ($gal_buddylist)")) : "AND id_member = $gal_member" ).'
         '.(empty($gal_disallowCats) ? "" : "   AND id_cat NOT IN ($gal_disallowCats)").'
         '.(empty($gal_allowCats) ? "" : "   AND id_cat IN ($gal_allowCats)").'
         GROUP BY thumbfilename ';

   switch ($gal_showtype){
      // most/least recent
      case 1:
         $gal_query .= '
               ORDER BY date '.$gal_sort_text;
         break;

      // most/least viewed
      case 2:
         $gal_query .= '
               ORDER BY views '.$gal_sort_text;
         break;

      // most/least commented
      case 3:
         $gal_query .= '
               ORDER BY commenttotal '.$gal_sort_text;
         break;

      default:
         $gal_query .= '
               ORDER BY rand() '.$gal_sort_text;
         break;
   }
   $gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';
   $gal_result = tp_query($gal_query, __FILE__, __LINE__);
   if (!$gal_result){
      // error retrieving information from database
      if (mysql_errno() == 1146){
         echo '<p />Error, no database found!<p />';
      } else {
         echo '<p />MySQL error:'.mysql_error().'<p />';
      }
   } else {
      echo "\n".'<table cellspacing="0" cellpadding="2" border="0" align="center" width="100%">'."\n";
   
      $gal_colcnt = 1;
      echo "   <tr>\n";

      while ($row = tpdb_fetch_assoc($gal_result)){
         if ($gal_colcnt > $gal_columns){
            // close out the row and start a new row
            echo "   </tr>\n   <tr>\n".'      <td colspan="'.$gal_columns.'"><hr /></td>'."\n   </tr>\n   <tr>\n";
            // reset count to column 1
            $gal_colcnt = 1;
         }
         echo   '      <td class="'.$gal_textclass.'" align="center">'."\n";
         // display title if enabled, make edit link if viewing user is picture poster
         if (!empty($gal_dispTitle)){
            echo "         ".($context['user']['id'] == $row['id_member'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;pic='.$row['id_picture'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
         }
         // display the picture thumbnail and link it to gallery full picture
         echo   '         <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'" /></a><br />'."\n";
         // display poster's name and posted date if enabled
         if (!empty($gal_dispMember) || !empty($gal_dispDate)){
            echo 'Owner:';
            if (!empty($gal_dispMember)){
               // display the member name who posted pic?  need to get name based on id_member
               $get_name_result = tp_query("SELECT member_name FROM ".$db_prefix."members WHERE id_member = ".$row['id_member'], __FILE__, __LINE__);
               $gal_tmp = tpdb_fetch_assoc($get_name_result);
               echo '  <a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$gal_tmp['member_name'].'</a>';
            }
            if (!empty($gal_dispDate)){
               // display the date it was posted
               echo ' on '.date("d M Y", $row['date']);
            }
            echo "<br />\n";
         }
         // display category if enabled
         if (!empty($gal_dispCategory)){
            // get category name based on category id
            $get_category_result = tp_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE id_cat = ".$row['id_cat'], __FILE__, __LINE__);
            $gal_tmp = tpdb_fetch_assoc($get_category_result);
   
            echo '<br />in<br /><a href="'.$scripturl.'?action=gallery;cat='.$row['id_cat'].'">'.$gal_tmp['title']."</a><br /><br />\n";
         }
         // display number of views if enabled
         if (!empty($gal_dispViews)){
            echo "Viewed ".$row['views']." times<br />\n";
         }
         // display dimensions if enabled
         if (!empty($gal_dispDimensions)){
            echo $row['width']."w X ".$row['height']."h<br />\n";
         }
         // display filesize if enabled
         if (!empty($gal_dispSize)){
            echo $row['filesize']." bytes<br />\n";
         }
         // display description if enabled
         if (!empty($gal_dispDescription)){
            echo "<br />".$row['description']."<br />\n";
         }
         // display # of comments if enabled
         if (!empty($gal_dispNumComments)){
            echo '<br /><i><a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'">'.$row['commenttotal']."</a> comment(s)</i><br />\n";
         }
         echo   "      </td>\n";
         $gal_colcnt++;
      }

      mysql_free_result($gal_result);

      echo "   </tr>\n</table>\n";
      if (!empty($gal_member) && empty($_GET['gal_viewall']))
         echo '<br /><a href="'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';
      if (!empty($gal_buddies) && empty($_GET['gal_viewall'])){
         // build the link
         $gal_querystring = $context['TPortal']['querystring'];
         $gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
         echo '<br /><a href="'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
      }
   }
} else {
   echo 'Sorry, you do not have permission to view pictures!';
}
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: ZarPrime on July 10, 2011, 05:10:59 PM
Hey Bluedevil.  Nice to see you again.  Is this with you using the latest TP as well, 1.0 RC2?  tp_query has been replaced in favor of the SMF 2.0 SMF functions in the latest versions.  Any block code snippets that use tp_query will need to be edited.  Freddy knows just what to do on these.  Can you give him a couple of days to look at it?

ZarPrime
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on July 10, 2011, 08:37:34 PM
Quote from: ZarPrime on July 10, 2011, 05:10:59 PM
Hey Bluedevil.  Nice to see you again.  Is this with you using the latest TP as well, 1.0 RC2?  tp_query has been replaced in favor of the SMF 2.0 SMF functions in the latest versions.  Any block code snippets that use tp_query will need to be edited.  Freddy knows just what to do on these.  Can you give him a couple of days to look at it?

ZarPrime

Hey ZP long time no see.... ;)

Yea bro, no problem :P
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on July 10, 2011, 09:07:37 PM
I'll take a look when I have a spare minute, I'm a bit tied up at the moment. Not in a pervy way...
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on July 11, 2011, 02:13:38 AM
Quote from: Freddy on July 10, 2011, 09:07:37 PM
I'll take a look when I have a spare minute, I'm a bit tied up at the moment. Not in a pervy way...

lol, no worries  :D
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on July 11, 2011, 01:09:10 PM
Try this out, I haven't tested all the options, but the settings you had seem to work okay.
I tidied up the code a bit too as it was a nightmare to read lol

Also changed $gal_disallowCats in the settings to use an array - same idea just made more sense to me.


////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.8          //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 9/26/2008
// 1.8
//      - added display # of comments option
//
// Updated 10 April 2010 by Freddy888 to work with SMF2
// Updated 12 July 2011 by Freddy888 to work with TP1
// Used in a TinyPortal phpblock or Article.
// This block displays random/most/least/newest/oldest picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

global $scripturl, $db_prefix, $modSettings, $boardurl, $user_info, $context, $smcFunc;

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 7;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 1;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 7;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 0;
// display membername who posted pic?
$gal_dispMember = 1;
// display posted date?
$gal_dispDate = 0;
// display category the picture is in?
$gal_dispCategory = 0;
// display number of views?
$gal_dispViews = 0;
// display dimensions?
$gal_dispDimensions = 0;
// display filesize?
$gal_dispSize = 0;
// display picture description?
$gal_dispDescription = 0;
// display # comments
$gal_dispNumComments = 0;

//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = array(4,2,7) - don't show categories 2, 4, or 7
$gal_disallowCats = array(3,4,13,15,16,17,155,172,175);
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

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

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
$gal_showtype = 0;

// sort text
if (empty($gal_sort))
{
$gal_sort_text = 'DESC';
}
else
{
$gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile")
{
$gal_member = empty($_GET['u']) ? $context['user']['id'] : $_GET['u'];
}
else
$gal_member = '';

// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view'))
{
$gal_query = '
SELECT
thumbfilename,
id_picture,
id_member,
date,
title,
description,
views,
filesize,
height,
width,
commenttotal,
id_cat
FROM {db_prefix}gallery_pic
WHERE approved = 1
'.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "
AND id_member = NULL " : "AND id_member IN ({array_int:gal_buddylist})")) : "AND id_member = {int:gal_member}" ).'
'.(empty($gal_disallowCats) ? "" : "   AND id_cat NOT IN ({array_int:gal_disallowCats})").'
'.(empty($gal_allowCats) ? "" : "   AND id_cat IN ({array_int:gal_allowCats})").'
GROUP BY thumbfilename ';

switch ($gal_showtype){
// most/least recent
case 1:
$gal_query .= '
ORDER BY date '.$gal_sort_text;
break;

// most/least viewed
case 2:
$gal_query .= '
ORDER BY views '.$gal_sort_text;
break;

// most/least commented
case 3:
$gal_query .= '
ORDER BY commenttotal '.$gal_sort_text;
break;

default:
$gal_query .= '
ORDER BY rand() '.$gal_sort_text;
break;
}

$gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';

$gal_result = $smcFunc['db_query']('', $gal_query ,
array(
'gal_buddylist' => $gal_buddylist,
'gal_member' => $gal_member,
'gal_disallowCats' => $gal_disallowCats,
'gal_allowCats' => $gal_allowCats,
)
);


if (!$gal_result)
{
$db_error = @$smcFunc['db_error']($db_connection);
echo '<p />MySQL error:'.$db_error.'<p />';
}
else
{
echo "\n".'
<table cellspacing="0" cellpadding="2" border="0" align="center" width="100%">'."\n";

$gal_colcnt = 1;
echo "
<tr>\n";

while ($row = $smcFunc['db_fetch_assoc']($gal_result))
{
if ($gal_colcnt > $gal_columns)
{
// close out the row and start a new row
echo "   </tr>\n   <tr>\n".'      <td colspan="'.$gal_columns.'"><hr /></td>'."\n   </tr>\n   <tr>\n";
// reset count to column 1
$gal_colcnt = 1;
}

echo   '      <td class="'.$gal_textclass.'" align="center">'."\n";

// display title if enabled, make edit link if viewing user is picture poster
if (!empty($gal_dispTitle))
{
echo "         ".($context['user']['id'] == $row['id_member'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;pic='.$row['id_picture'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
}

// display the picture thumbnail and link it to gallery full picture
echo   '         <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'" /></a><br />'."\n";

// display poster's name and posted date if enabled
if (!empty($gal_dispMember) || !empty($gal_dispDate))
{
echo 'Owner:';
if (!empty($gal_dispMember))
{

// display the member name who posted pic?  need to get name based on id_member
$get_name_result = $smcFunc['db_query']('' , '
SELECT member_name
FROM {db_prefix}members
WHERE id_member = {int:id_member}
LIMIT 1',
array (
'id_member' => $row['id_member'],
)
);

//$get_name_result = tp_query("SELECT member_name FROM ".$db_prefix."members WHERE id_member = ".$row['id_member'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_name_result);
echo '  <a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$gal_tmp['member_name'].'</a>';
}

if (!empty($gal_dispDate))
{
// display the date it was posted
echo ' on '.date("d M Y", $row['date']);
}
echo "<br />\n";
}

// display category if enabled
if (!empty($gal_dispCategory))
{
// get category name based on category id
$get_category_result = $smcFunc['db_query']('' , '
SELECT title
FROM {db_prefix}gallery_cat
WHERE id_cat = {int:id_cat}
LIMIT 1',
array (
'id_cat' => $row['id_cat'],
)
);

//$get_category_result = tp_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE id_cat = ".$row['id_cat'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_category_result);

echo '<br />in<br /><a href="'.$scripturl.'?action=gallery;cat='.$row['id_cat'].'">'.$gal_tmp['title']."</a><br /><br />\n";
}

// display number of views if enabled
if (!empty($gal_dispViews))
echo "Viewed ".$row['views']." times<br />\n";

// display dimensions if enabled
if (!empty($gal_dispDimensions))
echo $row['width']."w X ".$row['height']."h<br />\n";

// display filesize if enabled
if (!empty($gal_dispSize))
echo $row['filesize']." bytes<br />\n";

// display description if enabled
if (!empty($gal_dispDescription))
echo "<br />".$row['description']."<br />\n";

// display # of comments if enabled
if (!empty($gal_dispNumComments))
echo '<br /><i><a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'">'.$row['commenttotal']."</a> comment(s)</i><br />\n";

echo   "      </td>\n";
$gal_colcnt++;
}

$smcFunc['db_free_result']($gal_result);

echo "   </tr>\n</table>\n";
if (!empty($gal_member) && empty($_GET['gal_viewall']))
echo '<br /><a href="'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';

if (!empty($gal_buddies) && empty($_GET['gal_viewall']))
{
// build the link
$gal_querystring = $context['TPortal']['querystring'];
$gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
echo '<br /><a href="'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
}
}
}
else
{
echo 'Sorry, you do not have permission to view pictures!';
}
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Ken. on July 11, 2011, 01:45:25 PM
That works Freddy.  O0

Here's my test block. (http://www.ourfamilyforum.org/FamilyForum/index.php?action=forum)
... works OK, with no errors showing in the log.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on July 11, 2011, 01:53:50 PM
Cool  8)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: WillyP on July 11, 2011, 03:51:04 PM
Works so well you sliced your finger open on it.  :o
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Mick on July 11, 2011, 09:28:35 PM
Excellent!! Thank you.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Ken. on July 11, 2011, 10:26:13 PM
Quote from: WillyP on July 11, 2011, 03:51:04 PM
Works so well you sliced your finger open on it.  :o
Quote from: WillyP on July 11, 2011, 03:51:04 PM
Works so well you sliced your finger open on it.  :o
Ah... so you noticed that part Willy.  :)

That was not a fun event.  ^-^
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on August 09, 2011, 11:57:49 PM
Quote from: Freddy on July 05, 2010, 03:54:29 PM
Yes, I said image sizes could pose a problem with this if you read back a bit.

Two solutions :

1) Limit the size of images that people upload.

2) Force the browser to resize the full size image on the fly by editing the code :

Find this :

// display the picture thumbnail and link it to gallery full picture
echo ' <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['filename'].'" /></a><br />'."\n";


Replace it with something like this :

// display the picture and link it to gallery full picture
echo ' <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['filename'].'" width="650" /></a><br />'."\n";


Just change the width="650" to whatever width you want to rescale it to.  It should rescale height automatically I think.

Hi Tinyportal Support, nice to meet you!  :)
I have only a little question about thumbsnails resize. With this code I can reduce width and height dimension, fantastic!
There is possibility to crop thumbsnails so all picture are with same size?


Thank You very much!  :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on August 10, 2011, 12:30:22 PM
You can't do cropping with HTML.  The best you can do is set either the width or the height instead of both.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on August 11, 2011, 09:16:45 AM
OK Thank you Freddy....
I have found a script that crop images but work on link image:

/scripts/crop/resize.php?url=/gallery/thumb_138-280711154913.jpeg&size=100x100c50

It's possible to place in this code?

// display the picture thumbnail and link it to gallery full picture

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



Thank you  :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on August 11, 2011, 12:26:52 PM
Well you haven't given me much to go on so I guess this :

echo    '           
<a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['ID_PICTURE'].'">
<img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'&size=100x100c50" /></a><br />'."\n";
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on August 12, 2011, 01:31:28 AM
Tahnk you!
Work perfectly....

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fi51.tinypic.com%2Fs63peg.jpg&hash=b667a5b103486a91f1dbd9567fc9cceb580113c0)

a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['ID_PICTURE'].'" target="_blank">

<img src="http://www.yoursite.com/scriptfolder/resize.php?url='.$modSettings['gallery_url']

.$row['thumbfilename'].'&size=80x80c0" /></a><br />'."\n";


Here the script:

newbielink:http://fabrizio.zellini.org/resizer/dist/ [nonactive]

O0
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on August 12, 2011, 11:36:33 AM
No problem, looks great and thanks for the link, I think others will find it useful too  O0
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on January 12, 2012, 09:24:55 PM
Hi tinyportal,
I have only a little question, can I allow an ID instead a CAT (Code: $gal_allowCats or $gal_disallowCats) so in a block I can see image from a user gallery?

Thank You!

Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: MinatO on February 15, 2012, 07:06:57 PM
Tried the code in a php block, but i'm getting this msg:
Fatal error: Call to undefined function tp_query() in /home/cyberspo/public_html/Sources/Load.php(2203) : eval()'d code(114) : eval()'d code on line 173

And when I do it in an article to test, i get this:
Fatal error: Call to undefined function tp_query() in /home/cyberspo/public_html/Sources/TPSubs.php(1748) : eval()'d code on line 172

Any clue on what i'm doing wrong?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: lurkalot on February 15, 2012, 07:27:08 PM
Quote from: MinatO on February 15, 2012, 07:06:57 PM
Tried the code in a php block, but i'm getting this msg:
Fatal error: Call to undefined function tp_query() in /home/cyberspo/public_html/Sources/Load.php(2203) : eval()'d code(114) : eval()'d code on line 173

And when I do it in an article to test, i get this:
Fatal error: Call to undefined function tp_query() in /home/cyberspo/public_html/Sources/TPSubs.php(1748) : eval()'d code on line 172

Any clue on what i'm doing wrong?

Try this one, http://www.tinyportal.net/index.php?topic=32358.msg273522#msg273522
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: IchBin on February 15, 2012, 09:37:31 PM
Fixed your post Lurk, you had your reply inside the quote. :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: lurkalot on February 15, 2012, 10:20:45 PM
Quote from: IchBinâ,,¢ on February 15, 2012, 09:37:31 PM
Fixed your post Lurk, you had your reply inside the quote. :)

:-[  Thanks Brad..  O0
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: daveb47 on February 16, 2012, 09:15:07 AM
Hi,Having problems with this,using 2.02,Block shows but images dont.
Any help appreciated,Not new to this but recent hesrt bypass and meds not helping ::)
Board is work in progress
http://yourbestfriends.co.uk
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: G6Cad on February 16, 2012, 01:19:43 PM
It's probably because you have the wrong url put in for your images, when rightklick on them, you they should be located here for them to show up /gallery/thumb_1_16_02_12_9_10_22.gif
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: daveb47 on February 16, 2012, 02:03:45 PM
May be my brain not working,but thats where thumbnails are,but  they show as corrupted when viewed,
but thumbnails on my gallery are working ok but seem to come from this code.

<a href="http://yourbestfriends.co.uk/gallery/?sa=view;pic=1">
<img width="120" height="78" border="0" alt="" src="http://yourbestfriends.co.uk/gallery/1_15_02_12_8_37_29.jpeg">
</a>
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: G6Cad on February 16, 2012, 02:27:13 PM
Remove "yourbestfriend.uk" and use only the part url "/gallery/yourimage.jpg"
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: daveb47 on February 16, 2012, 04:24:45 PM
Where do i change this?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: IchBin on February 16, 2012, 04:46:17 PM
I don't see a block with any images. Looks like I can't view your site on more than 3 pages, so I can't be of any help anyway.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: daveb47 on February 16, 2012, 04:49:55 PM
I had turned block off,,now back on
also have disabled guest viewing block.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: IchBin on February 16, 2012, 05:49:47 PM
Looks to me like your image does not exist. For example:

The image you are pointing to is this:
http://yourbestfriends.co.uk/gallery/thumb_1_15_02_12_8_37_29.jpeg

Yet, there is no image there. The image is actually this:
http://yourbestfriends.co.uk/gallery/1_15_02_12_8_37_29.jpeg

What code are you using to make this block? Looks to me like you just need to change it to remove the "thumb_" part of the image, unless you actually have a thumbnail somewhere to actually use.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: daveb47 on February 18, 2012, 02:24:15 PM
This is script i am using,but cant work out what i need to change.

////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.8          //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 9/26/2008
// 1.8
//      - added display # of comments option
//
// Updated 10 April 2010 by Freddy888 to work with SMF2
// Updated 12 July 2011 by Freddy888 to work with TP1
// Used in a TinyPortal phpblock or Article.
// This block displays random/most/least/newest/oldest picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

global $scripturl, $db_prefix, $modSettings, $boardurl, $user_info, $context, $smcFunc;

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 7;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 1;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 7;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 0;
// display membername who posted pic?
$gal_dispMember = 1;
// display posted date?
$gal_dispDate = 0;
// display category the picture is in?
$gal_dispCategory = 0;
// display number of views?
$gal_dispViews = 0;
// display dimensions?
$gal_dispDimensions = 0;
// display filesize?
$gal_dispSize = 0;
// display picture description?
$gal_dispDescription = 0;
// display # comments
$gal_dispNumComments = 0;

//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = array(4,2,7) - don't show categories 2, 4, or 7
$gal_disallowCats = array();
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

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

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
$gal_showtype = 0;

// sort text
if (empty($gal_sort))
{
$gal_sort_text = 'DESC';
}
else
{
$gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile")
{
$gal_member = empty($_GET['u']) ? $context['user']['id'] : $_GET['u'];
}
else
$gal_member = '';

// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view'))
{
$gal_query = '
SELECT
thumbfilename,
id_picture,
id_member,
date,
title,
description,
views,
filesize,
height,
width,
commenttotal,
id_cat
FROM {db_prefix}gallery_pic
WHERE approved = 1
'.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "
AND id_member = NULL " : "AND id_member IN ({array_int:gal_buddylist})")) : "AND id_member = {int:gal_member}" ).'
'.(empty($gal_disallowCats) ? "" : "   AND id_cat NOT IN ({array_int:gal_disallowCats})").'
'.(empty($gal_allowCats) ? "" : "   AND id_cat IN ({array_int:gal_allowCats})").'
GROUP BY thumbfilename ';

switch ($gal_showtype){
// most/least recent
case 1:
$gal_query .= '
ORDER BY date '.$gal_sort_text;
break;

// most/least viewed
case 2:
$gal_query .= '
ORDER BY views '.$gal_sort_text;
break;

// most/least commented
case 3:
$gal_query .= '
ORDER BY commenttotal '.$gal_sort_text;
break;

default:
$gal_query .= '
ORDER BY rand() '.$gal_sort_text;
break;
}

$gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';

$gal_result = $smcFunc['db_query']('', $gal_query ,
array(
'gal_buddylist' => $gal_buddylist,
'gal_member' => $gal_member,
'gal_disallowCats' => $gal_disallowCats,
'gal_allowCats' => $gal_allowCats,
)
);


if (!$gal_result)
{
$db_error = @$smcFunc['db_error']($db_connection);
echo '<p />MySQL error:'.$db_error.'<p />';
}
else
{
echo "\n".'
<table cellspacing="0" cellpadding="2" border="0" align="center" width="100%">'."\n";

$gal_colcnt = 1;
echo "
<tr>\n";

while ($row = $smcFunc['db_fetch_assoc']($gal_result))
{
if ($gal_colcnt > $gal_columns)
{
// close out the row and start a new row
echo "   </tr>\n   <tr>\n".'      <td colspan="'.$gal_columns.'"><hr /></td>'."\n   </tr>\n   <tr>\n";
// reset count to column 1
$gal_colcnt = 1;
}

echo   '      <td class="'.$gal_textclass.'" align="center">'."\n";

// display title if enabled, make edit link if viewing user is picture poster
if (!empty($gal_dispTitle))
{
echo "         ".($context['user']['id'] == $row['id_member'] ? ('<a href="http://yourbestfriends.co.uk/'.$scripturl.'?action=gallery;sa=edit;pic='.$row['id_picture'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
}

// display the picture thumbnail and link it to gallery full picture
echo   '         <a href="http://yourbestfriends.co.uk/'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'" /></a><br />'."\n";

// display poster's name and posted date if enabled
if (!empty($gal_dispMember) || !empty($gal_dispDate))
{
echo 'Owner:';
if (!empty($gal_dispMember))
{

// display the member name who posted pic?  need to get name based on id_member
$get_name_result = $smcFunc['db_query']('' , '
SELECT member_name
FROM {db_prefix}members
WHERE id_member = {int:id_member}
LIMIT 1',
array (
'id_member' => $row['id_member'],
)
);

//$get_name_result = tp_query("SELECT member_name FROM ".$db_prefix."members WHERE id_member = ".$row['id_member'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_name_result);
echo '  <a href="http://yourbestfriends.co.uk/'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$gal_tmp['member_name'].'</a>';
}

if (!empty($gal_dispDate))
{
// display the date it was posted
echo ' on '.date("d M Y", $row['date']);
}
echo "<br />\n";
}

// display category if enabled
if (!empty($gal_dispCategory))
{
// get category name based on category id
$get_category_result = $smcFunc['db_query']('' , '
SELECT title
FROM {db_prefix}gallery_cat
WHERE id_cat = {int:id_cat}
LIMIT 1',
array (
'id_cat' => $row['id_cat'],
)
);

//$get_category_result = tp_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE id_cat = ".$row['id_cat'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_category_result);

echo '<br />in<br /><a href="http://yourbestfriends.co.uk/'.$scripturl.'?action=gallery;cat='.$row['id_cat'].'">'.$gal_tmp['title']."</a><br /><br />\n";
}

// display number of views if enabled
if (!empty($gal_dispViews))
echo "Viewed ".$row['views']." times<br />\n";

// display dimensions if enabled
if (!empty($gal_dispDimensions))
echo $row['width']."w X ".$row['height']."h<br />\n";

// display filesize if enabled
if (!empty($gal_dispSize))
echo $row['filesize']." bytes<br />\n";

// display description if enabled
if (!empty($gal_dispDescription))
echo "<br />".$row['description']."<br />\n";

// display # of comments if enabled
if (!empty($gal_dispNumComments))
echo '<br /><i><a href="http://yourbestfriends.co.uk/'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'">'.$row['commenttotal']."</a> comment(s)</i><br />\n";

echo   "      </td>\n";
$gal_colcnt++;
}

$smcFunc['db_free_result']($gal_result);

echo "   </tr>\n</table>\n";
if (!empty($gal_member) && empty($_GET['gal_viewall']))
echo '<br /><a href="http://yourbestfriends.co.uk/'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';

if (!empty($gal_buddies) && empty($_GET['gal_viewall']))
{
// build the link
$gal_querystring = $context['TPortal']['querystring'];
$gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
echo '<br /><a href="http://yourbestfriends.co.uk/'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
}
}
}
else
{
echo 'Sorry, you do not have permission to view pictures!';
}
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: G6Cad on February 18, 2012, 02:47:22 PM
In the part of the code where your site url is added, did you do that by your self?

You ( according to the description) should not edit anything below this part in the code. Yet i see your site url ( full url ) in several places. if you use the original code snippet and just edit the SETTING parts, does it work then ?
Quote/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: daveb47 on February 18, 2012, 03:38:36 PM
Script seems to add those itself,now tring this one with no alteration with same result.

Nas anyone actually got this working with 2.02 & gallery 3.1.1a

////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.8          //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 9/26/2008
// 1.8
//      - added display # of comments option
//
// Updated 10 April 2010 by Freddy888 to work with SMF2
// Updated 12 July 2011 by Freddy888 to work with TP1
// Used in a TinyPortal phpblock or Article.
// This block displays random/most/least/newest/oldest picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

global $scripturl, $db_prefix, $modSettings, $boardurl, $user_info, $context, $smcFunc;

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 7;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 1;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 7;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 0;
// display membername who posted pic?
$gal_dispMember = 1;
// display posted date?
$gal_dispDate = 0;
// display category the picture is in?
$gal_dispCategory = 0;
// display number of views?
$gal_dispViews = 0;
// display dimensions?
$gal_dispDimensions = 0;
// display filesize?
$gal_dispSize = 0;
// display picture description?
$gal_dispDescription = 0;
// display # comments
$gal_dispNumComments = 0;

//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = array(4,2,7) - don't show categories 2, 4, or 7
$gal_disallowCats = array(3,4,13,15,16,17,155,172,175);
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

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

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
$gal_showtype = 0;

// sort text
if (empty($gal_sort))
{
$gal_sort_text = 'DESC';
}
else
{
$gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile")
{
$gal_member = empty($_GET['u']) ? $context['user']['id'] : $_GET['u'];
}
else
$gal_member = '';

// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view'))
{
$gal_query = '
SELECT
thumbfilename,
id_picture,
id_member,
date,
title,
description,
views,
filesize,
height,
width,
commenttotal,
id_cat
FROM {db_prefix}gallery_pic
WHERE approved = 1
'.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "
AND id_member = NULL " : "AND id_member IN ({array_int:gal_buddylist})")) : "AND id_member = {int:gal_member}" ).'
'.(empty($gal_disallowCats) ? "" : "   AND id_cat NOT IN ({array_int:gal_disallowCats})").'
'.(empty($gal_allowCats) ? "" : "   AND id_cat IN ({array_int:gal_allowCats})").'
GROUP BY thumbfilename ';

switch ($gal_showtype){
// most/least recent
case 1:
$gal_query .= '
ORDER BY date '.$gal_sort_text;
break;

// most/least viewed
case 2:
$gal_query .= '
ORDER BY views '.$gal_sort_text;
break;

// most/least commented
case 3:
$gal_query .= '
ORDER BY commenttotal '.$gal_sort_text;
break;

default:
$gal_query .= '
ORDER BY rand() '.$gal_sort_text;
break;
}

$gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';

$gal_result = $smcFunc['db_query']('', $gal_query ,
array(
'gal_buddylist' => $gal_buddylist,
'gal_member' => $gal_member,
'gal_disallowCats' => $gal_disallowCats,
'gal_allowCats' => $gal_allowCats,
)
);


if (!$gal_result)
{
$db_error = @$smcFunc['db_error']($db_connection);
echo '<p />MySQL error:'.$db_error.'<p />';
}
else
{
echo "\n".'
<table cellspacing="0" cellpadding="2" border="0" align="center" width="100%">'."\n";

$gal_colcnt = 1;
echo "
<tr>\n";

while ($row = $smcFunc['db_fetch_assoc']($gal_result))
{
if ($gal_colcnt > $gal_columns)
{
// close out the row and start a new row
echo "   </tr>\n   <tr>\n".'      <td colspan="'.$gal_columns.'"><hr /></td>'."\n   </tr>\n   <tr>\n";
// reset count to column 1
$gal_colcnt = 1;
}

echo   '      <td class="'.$gal_textclass.'" align="center">'."\n";

// display title if enabled, make edit link if viewing user is picture poster
if (!empty($gal_dispTitle))
{
echo "         ".($context['user']['id'] == $row['id_member'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;pic='.$row['id_picture'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
}

// display the picture thumbnail and link it to gallery full picture
echo   '         <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'" /></a><br />'."\n";

// display poster's name and posted date if enabled
if (!empty($gal_dispMember) || !empty($gal_dispDate))
{
echo 'Owner:';
if (!empty($gal_dispMember))
{

// display the member name who posted pic?  need to get name based on id_member
$get_name_result = $smcFunc['db_query']('' , '
SELECT member_name
FROM {db_prefix}members
WHERE id_member = {int:id_member}
LIMIT 1',
array (
'id_member' => $row['id_member'],
)
);

//$get_name_result = tp_query("SELECT member_name FROM ".$db_prefix."members WHERE id_member = ".$row['id_member'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_name_result);
echo '  <a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$gal_tmp['member_name'].'</a>';
}

if (!empty($gal_dispDate))
{
// display the date it was posted
echo ' on '.date("d M Y", $row['date']);
}
echo "<br />\n";
}

// display category if enabled
if (!empty($gal_dispCategory))
{
// get category name based on category id
$get_category_result = $smcFunc['db_query']('' , '
SELECT title
FROM {db_prefix}gallery_cat
WHERE id_cat = {int:id_cat}
LIMIT 1',
array (
'id_cat' => $row['id_cat'],
)
);

//$get_category_result = tp_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE id_cat = ".$row['id_cat'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_category_result);

echo '<br />in<br /><a href="'.$scripturl.'?action=gallery;cat='.$row['id_cat'].'">'.$gal_tmp['title']."</a><br /><br />\n";
}

// display number of views if enabled
if (!empty($gal_dispViews))
echo "Viewed ".$row['views']." times<br />\n";

// display dimensions if enabled
if (!empty($gal_dispDimensions))
echo $row['width']."w X ".$row['height']."h<br />\n";

// display filesize if enabled
if (!empty($gal_dispSize))
echo $row['filesize']." bytes<br />\n";

// display description if enabled
if (!empty($gal_dispDescription))
echo "<br />".$row['description']."<br />\n";

// display # of comments if enabled
if (!empty($gal_dispNumComments))
echo '<br /><i><a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'">'.$row['commenttotal']."</a> comment(s)</i><br />\n";

echo   "      </td>\n";
$gal_colcnt++;
}

$smcFunc['db_free_result']($gal_result);

echo "   </tr>\n</table>\n";
if (!empty($gal_member) && empty($_GET['gal_viewall']))
echo '<br /><a href="'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';

if (!empty($gal_buddies) && empty($_GET['gal_viewall']))
{
// build the link
$gal_querystring = $context['TPortal']['querystring'];
$gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
echo '<br /><a href="'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
}
}
}
else
{
echo 'Sorry, you do not have permission to view pictures!';
}
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Dylert on February 22, 2012, 11:10:24 AM
Hi! Is it possible to add "Last comments"   in this block? There is already a "most comments" option....maybe that could be changed to "last comments"? I'm not able to do this myself, so maybe someone can help?  :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on April 18, 2012, 11:10:17 PM
 :)
Hi,
how can I randomize for example "most commented" independently how many pictures do you want to show? It's possible?

Thank you very much!  :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on April 20, 2012, 09:17:30 PM
 :)

No solution? Thank You....
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: ZarPrime on April 20, 2012, 09:35:18 PM
Quote from: NeoX on April 18, 2012, 11:10:17 PM
how can I randomize for example "most commented" independently how many pictures do you want to show? It's possible?

NeoX,

I'm not sure that I understand what it is you are wanting to do with this code.  Could you please explain a little better and maybe one of us can take a look?

ZarPrime
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on April 20, 2012, 10:54:54 PM
Hi Zarprime,
yes excuse me....

For example I have 50 image with most commented setting. This 50 image can "sort" only Ascending or Descending.
It's possible to randomize this 50 image as the option "Use random"?

Thank You very much.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: ZarPrime on April 20, 2012, 11:00:00 PM
Not sure.  Post the exact code you are using and I'll take a look at it.  I'm not familiar with this block code so give me a couple of days to see if I can figure out how to do that once you post the code.

ZarPrime
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: NeoX on April 20, 2012, 11:22:18 PM
No Problem Zarprime.... the code however it's the Gallery Block Code:
Thank You!

:)

////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.8          //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 9/26/2008
// 1.8
//      - added display # of comments option
//
// Updated 10 April 2010 by Freddy888 to work with SMF2
// Updated 12 July 2011 by Freddy888 to work with TP1
// Used in a TinyPortal phpblock or Article.
// This block displays random/most/least/newest/oldest picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////

global $scripturl, $db_prefix, $modSettings, $boardurl, $user_info, $context, $smcFunc;

/*
****************************************
****************************************
***    !! Admin Config Section !!    ***
****************************************
****************************************
*/

//   *****   LAYOUT OPTIONS   *****
// how many pictures do you want to show?  0 = all!
$gal_numpics = 7;

// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 1;
// sort :: 0 = Descending, 1 = Ascending
$gal_sort = 0;

// enable profile pics display?
// 0 = disable, 1 = enable --- if enabled, and you are viewing a member profile, show pics from that member only
// other options still apply (showtype, sort order, etc)
$gal_profile = 1;

// only show pics from buddies?
// 0 = disable, 1 = enable --- if enabled, will only show pics posted by members in your buddy list
$gal_buddies = 0;

// use Normal Size Text, or Small Size Text? (0 = Normal Size, 1 = Small Size)
$gal_smalltext = 1;

// put pictures in how many columns?  (1 for left/right block, more for centerblock / article if you wish)
$gal_columns = 7;

// information display flags (0 = No, 1 = Yes)
// display picture title?
$gal_dispTitle = 0;
// display membername who posted pic?
$gal_dispMember = 1;
// display posted date?
$gal_dispDate = 0;
// display category the picture is in?
$gal_dispCategory = 0;
// display number of views?
$gal_dispViews = 0;
// display dimensions?
$gal_dispDimensions = 0;
// display filesize?
$gal_dispSize = 0;
// display picture description?
$gal_dispDescription = 0;
// display # comments
$gal_dispNumComments = 0;

//   *****   SECURITY CONFIGURATION   *****
// do not allow the following category numbers to be displayed
// example: $gal_disallowCats = array(4,2,7) - don't show categories 2, 4, or 7
$gal_disallowCats = array(3,4,13,15,16,17,155,172,175);
// select only from the following cats - leave empty for all - NOTE:($gal_disallowCats overrides)
// example: $gal_allowCats = "1,3,4" - show only categories 1, 3, and 4
$gal_allowCats = "";
// Require the user has allowedTo('smfgallery_view') permission to view random pics thumbnails in block?
$gal_viewPermission = 1;

/*
****************************************
****************************************
***  !! END Admin Config Section !!  ***
****************************************
****************************************
*/

//###############################################
//###############################################
//   You shouldn't change anything below here
//###############################################
//###############################################

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

$gal_textclass = empty($gal_smalltext) ? "normaltext" : "smalltext";

// get this user's buddy list
$gal_buddylist = implode(",", $user_info['buddies']);

// prep for our switch routine
if (empty($gal_showtype))
$gal_showtype = 0;

// sort text
if (empty($gal_sort))
{
$gal_sort_text = 'DESC';
}
else
{
$gal_sort_text = '';
}

// are we viewing a member profile and $gal_profile is enabled?
if (!empty($gal_profile) && strtolower($context['current_action']) == "profile")
{
$gal_member = empty($_GET['u']) ? $context['user']['id'] : $_GET['u'];
}
else
$gal_member = '';

// allow member to view random pic based on security settings
if (empty($gal_viewPermission) || allowedTo('smfgallery_view'))
{
$gal_query = '
SELECT
thumbfilename,
id_picture,
id_member,
date,
title,
description,
views,
filesize,
height,
width,
commenttotal,
id_cat
FROM {db_prefix}gallery_pic
WHERE approved = 1
'.(empty($gal_member) ? (empty($gal_buddies) ? "" : (empty($gal_buddylist) ? "
AND id_member = NULL " : "AND id_member IN ({array_int:gal_buddylist})")) : "AND id_member = {int:gal_member}" ).'
'.(empty($gal_disallowCats) ? "" : "   AND id_cat NOT IN ({array_int:gal_disallowCats})").'
'.(empty($gal_allowCats) ? "" : "   AND id_cat IN ({array_int:gal_allowCats})").'
GROUP BY thumbfilename ';

switch ($gal_showtype){
// most/least recent
case 1:
$gal_query .= '
ORDER BY date '.$gal_sort_text;
break;

// most/least viewed
case 2:
$gal_query .= '
ORDER BY views '.$gal_sort_text;
break;

// most/least commented
case 3:
$gal_query .= '
ORDER BY commenttotal '.$gal_sort_text;
break;

default:
$gal_query .= '
ORDER BY rand() '.$gal_sort_text;
break;
}

$gal_query .= (empty($_GET['gal_viewall']) && !empty($gal_numpics)) ? ' LIMIT '.$gal_numpics : '';

$gal_result = $smcFunc['db_query']('', $gal_query ,
array(
'gal_buddylist' => $gal_buddylist,
'gal_member' => $gal_member,
'gal_disallowCats' => $gal_disallowCats,
'gal_allowCats' => $gal_allowCats,
)
);


if (!$gal_result)
{
$db_error = @$smcFunc['db_error']($db_connection);
echo '<p />MySQL error:'.$db_error.'<p />';
}
else
{
echo "\n".'
<table cellspacing="0" cellpadding="2" border="0" align="center" width="100%">'."\n";

$gal_colcnt = 1;
echo "
<tr>\n";

while ($row = $smcFunc['db_fetch_assoc']($gal_result))
{
if ($gal_colcnt > $gal_columns)
{
// close out the row and start a new row
echo "   </tr>\n   <tr>\n".'      <td colspan="'.$gal_columns.'"><hr /></td>'."\n   </tr>\n   <tr>\n";
// reset count to column 1
$gal_colcnt = 1;
}

echo   '      <td class="'.$gal_textclass.'" align="center">'."\n";

// display title if enabled, make edit link if viewing user is picture poster
if (!empty($gal_dispTitle))
{
echo "         ".($context['user']['id'] == $row['id_member'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;pic='.$row['id_picture'].'">'.$row['title'].'</a>') : $row['title'])."<br />\n";
}

// display the picture thumbnail and link it to gallery full picture
echo   '         <a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'"><img src="'.$modSettings['gallery_url'].$row['thumbfilename'].'" /></a><br />'."\n";

// display poster's name and posted date if enabled
if (!empty($gal_dispMember) || !empty($gal_dispDate))
{
echo 'Owner:';
if (!empty($gal_dispMember))
{

// display the member name who posted pic?  need to get name based on id_member
$get_name_result = $smcFunc['db_query']('' , '
SELECT member_name
FROM {db_prefix}members
WHERE id_member = {int:id_member}
LIMIT 1',
array (
'id_member' => $row['id_member'],
)
);

//$get_name_result = tp_query("SELECT member_name FROM ".$db_prefix."members WHERE id_member = ".$row['id_member'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_name_result);
echo '  <a href="'.$scripturl.'?action=profile;u='.$row['id_member'].'">'.$gal_tmp['member_name'].'</a>';
}

if (!empty($gal_dispDate))
{
// display the date it was posted
echo ' on '.date("d M Y", $row['date']);
}
echo "<br />\n";
}

// display category if enabled
if (!empty($gal_dispCategory))
{
// get category name based on category id
$get_category_result = $smcFunc['db_query']('' , '
SELECT title
FROM {db_prefix}gallery_cat
WHERE id_cat = {int:id_cat}
LIMIT 1',
array (
'id_cat' => $row['id_cat'],
)
);

//$get_category_result = tp_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE id_cat = ".$row['id_cat'], __FILE__, __LINE__);
$gal_tmp = $smcFunc['db_fetch_assoc']($get_category_result);

echo '<br />in<br /><a href="'.$scripturl.'?action=gallery;cat='.$row['id_cat'].'">'.$gal_tmp['title']."</a><br /><br />\n";
}

// display number of views if enabled
if (!empty($gal_dispViews))
echo "Viewed ".$row['views']." times<br />\n";

// display dimensions if enabled
if (!empty($gal_dispDimensions))
echo $row['width']."w X ".$row['height']."h<br />\n";

// display filesize if enabled
if (!empty($gal_dispSize))
echo $row['filesize']." bytes<br />\n";

// display description if enabled
if (!empty($gal_dispDescription))
echo "<br />".$row['description']."<br />\n";

// display # of comments if enabled
if (!empty($gal_dispNumComments))
echo '<br /><i><a href="'.$scripturl.'?action=gallery;sa=view;id='.$row['id_picture'].'">'.$row['commenttotal']."</a> comment(s)</i><br />\n";

echo   "      </td>\n";
$gal_colcnt++;
}

$smcFunc['db_free_result']($gal_result);

echo "   </tr>\n</table>\n";
if (!empty($gal_member) && empty($_GET['gal_viewall']))
echo '<br /><a href="'.$boardurl.'/index.php?action=profile;u='.$gal_member.';gal_viewall=1">View all pics from this member</a>';

if (!empty($gal_buddies) && empty($_GET['gal_viewall']))
{
// build the link
$gal_querystring = $context['TPortal']['querystring'];
$gal_querystring .= empty($gal_querystring) ? 'gal_viewall=1' : ';gal_viewall=1';
echo '<br /><a href="'.$boardurl.'/index.php?'.$gal_querystring.'">View all pics of buddies</a>';
}
}
}
else
{
echo 'Sorry, you do not have permission to view pictures!';
}


Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: ZarPrime on April 20, 2012, 11:34:47 PM
Hmmm, just did a quick look at this code and it appears that it can be set for random ...

Code (Find This) Select
// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 1;


Code (and Change to This) Select
// use random, or most recent pics?
// 0 = random, 1 = most recent, 2 = most viewed, 3 = most commented
$gal_showtype = 0;


NeoX, did you try that?

ZarPrime
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: lurkalot on April 20, 2012, 11:40:30 PM
Not sure I'm understanding correctly, but

For random, you need to change this line $gal_showtype = 1;  to $gal_showtype = 0;

And for the number of pics,

Change this line from, $gal_numpics = 7;
  to any number you want, 0 = all
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Dylert on September 22, 2012, 10:21:20 PM
Is it possible to add "Latest comments" to this block?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on September 23, 2012, 01:02:10 PM
There is a a setting :

// display # comments
$gal_dispNumComments = 0;


I assume this is what you require..
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Dylert on September 23, 2012, 03:57:32 PM
Thanks a lot for the reply, Freddy! :) What you suggest is not actually what I need. I need a block that shows the latest commented pictures with the comments (not the latest pictures with comments).  I think it should be easy to add that feature to this mod, but unfortunately I don't have the skills to do it.

Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Freddy on September 25, 2012, 02:05:10 PM
I don't know if it's possible to be honest.  I'm not doing any coding at the moment and I don't have a test site set up.  I have been in hospital and it's all forms, doctor appointments and blood tests for me, so I can't really help this time. Maybe someone else has an idea.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: adambean on February 03, 2015, 12:27:47 PM
Hi, is this still being supported? I have an older script (1.7.1) that is breaking on a few things so I came and found this. Sadly, it breaks:

Fatal error: Call to undefined function tp_query() in /Sources/Load.php(2156) : eval()'d code(127) : eval()'d code on line 173

Any suggestions?

Thanks!
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: bloc on February 03, 2015, 04:19:06 PM
That function is phased out and no longer used, at least not in TP for SMF 2.0.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: lurkalot on February 03, 2015, 05:44:46 PM
Quote from: adambean on February 03, 2015, 12:27:47 PM
Hi, is this still being supported? I have an older script (1.7.1) that is breaking on a few things so I came and found this. Sadly, it breaks:

Fatal error: Call to undefined function tp_query() in /Sources/Load.php(2156) : eval()'d code(127) : eval()'d code on line 173

Any suggestions?

Thanks!

Quote from: bloc on February 03, 2015, 04:19:06 PM
That function is phased out and no longer used, at least not in TP for SMF 2.0.

Freddy updated it to work here, http://www.tinyportal.net/index.php?topic=32358.msg273522#msg273522

@ adambean, it's on your site now.  ;)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: bloc on February 03, 2015, 06:27:40 PM
ah. :)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: goten22 on July 31, 2017, 01:39:15 AM
It's been quite some time but maybe someone will be able to help me.

Im looking for a way to put this code into my own divs. I'm looking for a way to display recent images from specific album with specific start item and creator name and image title.

I'm using Aeva Media but this gallery is no longer supported. Here is aeva code with my divs. It's based on foreach and is very easy to modify.


require_once($sourcedir . '/Aeva-Subs.php');   
$aeva_start = 1;                   // where item number to start at
$aeva_limit = 3;                  // maximum number of items to display
$aeva_sort = 'm.time_added DESC';  // sort see Aeva-Subs.php for values I use 'RAND()' or 'm.time_added DESC' DESC or ASC for sorting order
$aeva_all_albums = true;           // all albums .. true or false 
$aeva_albums = array(1);            // for a single album put eg: array(10) for an array of albums eg: array(3,5,7) for all albums eg:array()

$items = aeva_getMediaItems($aeva_start,$aeva_limit,$aeva_sort,$aeva_all_albums,$aeva_albums);


echo'<div style="width:20%; height:300px; text-align:center; float:left; overflow:hidden;">';

foreach ($items as $item) {
echo'
<a href="', $galurl, 'sa=item;id=', $item['id'], '#itembox">
<div id="wyr" style="margin: 0 0 2px; padding:10px; display: inline-block; text-align:center; background-image:url(', $galurl, 'sa=media;id=', $item['id'], '); background-repeat:no-repeat; background-color: #000; background-position: center; background-size: cover; width:100%; height:100px;">
<br>
', $item['title'], '
<br>
<i class="fa fa-eye"></i>: ', $item['views'], '<br />
<i class="fa fa-user"></i>: ', $item['desc'], '<br><br>

</div>
</a>';
};
echo'</div>';


Maybe is there a way to simplify smf gallery code, to foreach maybe? Or whatever so I could put it into my divs?
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Ramzesito on November 29, 2017, 08:37:44 AM
hello,
does anybody support this mod now?

it was working until I updated SMF (from 2.0.13 to 2.0.14),
after that I've got error message instead of picture:
MySQL error:Access denied for user ''@'localhost' (using password: NO)

I`m using SMF Gallery Random Picture-ver.1.7.1 and SMF Gallery LITE 6.0
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: vbgamer45 on December 01, 2017, 02:00:34 AM
Quote from: Ramzesito on November 29, 2017, 08:37:44 AM
hello,
does anybody support this mod now?

it was working until I updated SMF (from 2.0.13 to 2.0.14),
after that I've got error message instead of picture:
MySQL error:Access denied for user ''@'localhost' (using password: NO)

I`m using SMF Gallery Random Picture-ver.1.7.1 and SMF Gallery LITE 6.0
If you are using this block code use the updated on for SMF 2.0 at
https://www.tinyportal.net/index.php?topic=32358.msg278635#msg278635
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: VladTepes on December 01, 2017, 07:03:04 AM
Quote from: Ramzesito on November 29, 2017, 08:37:44 AM
hello,
does anybody support this mod now?

it was working until I updated SMF (from 2.0.13 to 2.0.14),
after that I've got error message instead of picture:
MySQL error:Access denied for user ''@'localhost' (using password: NO)

I`m using SMF Gallery Random Picture-ver.1.7.1 and SMF Gallery LITE 6.0

While it's unlikely to be this, if the rest of your forum is working - make sure that your server is using the appropriate version of PHP - for SMF 2.0.14 it needs to be 5.4 or higher.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Ramzesito on December 12, 2017, 07:49:35 PM
Quote from: vbgamer45 on December 01, 2017, 02:00:34 AM
If you are using this block code use the updated on for SMF 2.0 at
https://www.tinyportal.net/index.php?topic=32358.msg278635#msg278635

thank you, this update is working!)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Oldiesmann on June 12, 2019, 11:46:41 PM
Is there an updated version of this? I tried it in SMF 2.1 and it didn't work because tp_query() wasn't defined. However, it also includes several calls to mysql_ functions which won't work anymore either.
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: lurkalot on June 13, 2019, 12:09:21 AM
Quote from: Oldiesmann on June 12, 2019, 11:46:41 PM
Is there an updated version of this? I tried it in SMF 2.1 and it didn't work because tp_query() wasn't defined. However, it also includes several calls to mysql_ functions which won't work anymore either.

Think the latest modified one is here, uses $smcFunc;

https://www.tinyportal.net/index.php?topic=32358.msg277437#msg277437
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: Oldiesmann on June 14, 2019, 04:15:28 AM
Quote from: lurkalot on June 13, 2019, 12:09:21 AM
Quote from: Oldiesmann on June 12, 2019, 11:46:41 PM
Is there an updated version of this? I tried it in SMF 2.1 and it didn't work because tp_query() wasn't defined. However, it also includes several calls to mysql_ functions which won't work anymore either.

Think the latest modified one is here, uses $smcFunc;

https://www.tinyportal.net/index.php?topic=32358.msg277437#msg277437

That one worked, but I had to edit Subs-Db-Mysql.php to remove "ONLY_FULL_GROUP_BY" from the SQL modes list (otherwise it was throwing an error about id_picture not being in the GROUP BY clause - easier to just leave the query as is instead of adding each column it complains about or figure out how to rewrite the query...)
Title: Re: [Discuss] SMF Gallery Block for SMF2
Post by: lurkalot on June 14, 2019, 07:07:54 AM
Quote from: Oldiesmann on June 14, 2019, 04:15:28 AM
Quote from: lurkalot on June 13, 2019, 12:09:21 AM
Quote from: Oldiesmann on June 12, 2019, 11:46:41 PM
Is there an updated version of this? I tried it in SMF 2.1 and it didn't work because tp_query() wasn't defined. However, it also includes several calls to mysql_ functions which won't work anymore either.

Think the latest modified one is here, uses $smcFunc;

https://www.tinyportal.net/index.php?topic=32358.msg277437#msg277437


That one worked, but I had to edit Subs-Db-Mysql.php to remove "ONLY_FULL_GROUP_BY" from the SQL modes list (otherwise it was throwing an error about id_picture not being in the GROUP BY clause - easier to just leave the query as is instead of adding each column it complains about or figure out how to rewrite the query...)

Glad you got something out of it at least.  :) 

Unfortunately quite a few of the block codes need updating as they are very old. we don't have anyone working on these atm.