SMFHacks.com
SMFHacks
Community Suite
SMF Gallery Pro
SMF Store
SMF Classifieds
Newsletter Pro
Downloads System Pro
Ad Seller Pro
Badge Awards
Hacks and Mods
Latest SMF Hacks
TopTen Hacks
Styles and Themes
Add a Hack
Manage Hacks
Earn Money from Your Forum with these tips
SMF Theme Generator
SMF Package Parser
Free SMF Hosting
Buy Website Traffic
Site Showcase
Email Marketing Software
Search Forums
Advanced search
User
Welcome,
Guest
. Please
login
or
register
.
May 21, 2013, 10:52:55 pm
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Stats
Members
Total Members: 10764
Latest:
ozzie4x4
Stats
Total Posts: 32371
Total Topics: 5478
Online Today: 70
Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Users: 1
Guests: 47
Total: 48
Bionic Rooster
SMFHacks.com
Forum
SMF Gallery Lite
SMF Gallery Lite
Random Image in Block?
0 Members and 1 Guest are viewing this topic.
« previous
next »
Pages:
1
...
6
7
[
8
]
Author
Topic: Random Image in Block? (Read 78815 times)
smartmouse
Inline PM Customer
Offline
Posts: 21
Re: Random Image in Block?
«
Reply #105 on:
December 20, 2007, 05:52:26 pm »
Quote from: SMFHacks on December 19, 2007, 09:29:09 pm
Change
WHERE ID_CAT = $cat
To
WHERE ID_CAT = $cat OR ID_CAT = anothercategorynumber
I have a lot of categories! How to set that the it has to get any category number?
Logged
SMFHacks
Administrator
Hero Member
Offline
Posts: 10995
Re: Random Image in Block?
«
Reply #106 on:
December 21, 2007, 11:30:25 pm »
If you want all the categories just remove the
WHERE ID_CAT = $cat
Logged
smartmouse
Inline PM Customer
Offline
Posts: 21
Re: Random Image in Block?
«
Reply #107 on:
December 22, 2007, 07:42:24 pm »
Quote from: SMFHacks on December 21, 2007, 11:30:25 pm
If you want all the categories just remove the
WHERE ID_CAT = $cat
It worked! Thank you so much!
Logged
tatore
Inline PM Customer
Offline
Posts: 13
Re: Random Image in Block?
«
Reply #108 on:
January 22, 2008, 06:52:17 am »
That's a way to show the thumbs in a superbe look, I always loved the Protocultura's website, really.
Quote from: SMFHacks on November 20, 2006, 10:12:09 am
oh that code won't work since SSI requires that it be loaded before all php
You would need to replace ssi_galleryrandom(); in your index.template.ph with something like
Code:
global $scripturl,$db_prefix,$modSettings,$boardurl;
if(empty($modSettings['gallery_url']))
{
$modSettings['gallery_url'] = $boardurl . '/gallery/';
}
$request = db_query("SELECT thumbfilename,ID_PICTURE,filename FROM
{$db_prefix}gallery_pic GROUP BY thumbfilename ORDER BY RAND() LIMIT 1", __FILE__,
__LINE__);
$row = mysql_fetch_assoc($request);
mysql_free_result($request);
echo' <center><a href="', $scripturl, '?action=gallery;sa=view;id=',
$row['ID_PICTURE'], '"><img src="', $modSettings['gallery_url'] .
$row['thumbfilename'] ,'" /></a></center>'
;
?><script language="javascript" type="text/javascript">
<!--
function linkingcodes() {
newwindow2=window.open('','name','height=250,width=800,scrollbars=yes');
var tmp = newwindow2.document;
tmp.write('<html><head><title>Linking codes</title>');
tmp.write('');
tmp.write('</head><body bgcolor="#FFFFFF"><center><font color="#000000" size="1" face="verdana">');
tmp.write('HTML For Websites:</br><form><textarea rows="2" cols="90"><a href="<?echo $modSettings['gallery_url'].$row['filename']; ?>"><img src="<?echo $modSettings['gallery_url'].$row['thumbfilename'];?>"></a></textarea></form> ');
tmp.write('</br></br>BBC For Forums</br><form><textarea rows="2" cols="90">[url=<?echo $modSettings['gallery_url'].$row['filename']; ?>][img]<?echo $modSettings['gallery_url'].$row['thumbfilename'];?>[/img][/url]</textarea></form>');
tmp.write('</font></center></body></html>');
tmp.close();
}
// -->
</script><center><form>
</br><input type="button" onClick="return linkingcodes()" value="Linking codes!">
</form></center>
<?
Unfortunately I didn't find any way to put the code into index.template and then see itwork properly.
SmfHack, when you have a chance..
I'm using DilberMc.
I'd coded the boardindex.template file to show the pics into the infocenter side, but for the tons of queries generated I've gave up.
However, in a test site I'd like to see the effect they have if I will be able to show them under the main user bar.
index.template.php
(39.82 KB - downloaded 495 times.)
Logged
smartmouse
Inline PM Customer
Offline
Posts: 21
Re: Random Image in Block?
«
Reply #109 on:
March 13, 2008, 04:34:03 pm »
Where to paste this code?
Can i see a demo?
Logged
dark4sorrow
Inline PM Customer
Offline
Posts: 1
Re: Random Image in Block?
«
Reply #110 on:
March 17, 2008, 03:51:38 pm »
I just used this code with SMF 1.1.4 and TinyPortal v0.9.8 and it worked perfectly.
Just thought I'd add in my 2 cents here.
-sorrow
Quote from: RWL on May 25, 2007, 06:21:05 am
Use this snippet from Thurnock over at TP - works great for me!
Code:
////////////////////////////////////////////////////
// SMF Gallery Random Picture - ver. 1.7.1 //
////////////////////////////////////////////////////
//
// Developed by Thurnok
// Thurnok -AT- tinyportal .DOT. net
// November 30, 2006
//
// Updated 5/9/2007
// 1.7.1
//
- quick fix to parsing the url
//
// Updated 5/9/2007
// 1.7
//
- added option to view pics that members on your buddy list posted
//
// For list of all previous updates history, see the UPDATES.TXT attached file
// in the post where you got this code, or the .ZIP file if you downloaded it
//
// Used in a TinyPortal phpblock or Article.
// This block displays random picture(s) from
// the SMF Gallery mod along with other information
//
//////////////////////////////////////////////
global $scripturl, $db_prefix, $modSettings, $boardurl, $ID_MEMBER, $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;
// ***** 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']) ? $ID_MEMBER : $_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 = mysql_query($gal_query);
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 = mysql_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 "
".($ID_MEMBER == $row['ID_MEMBER'] ? ('<a href="'.$scripturl.'?action=gallery;sa=edit;id='.$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 membername who posted pic? need to get name based on ID_MEMBER
$gal_tmp = mysql_fetch_assoc(mysql_query("SELECT memberName FROM ".$db_prefix."members WHERE ID_MEMBER = ".$row['ID_MEMBER']));
echo ' by <a href="'.$scripturl.'?action=profile;u='.$row['ID_MEMBER'].'">'.$gal_tmp['memberName'].'</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
$gal_tmp = mysql_fetch_assoc(mysql_query("SELECT title FROM ".$db_prefix."gallery_cat WHERE ID_CAT = ".$row['ID_CAT']));
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";
}
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!';
}
Logged
Raji
Inline PM Customer
Offline
Posts: 10
Re: Random Image in Block?
«
Reply #111 on:
March 08, 2009, 11:16:22 am »
Plz advice how can i display 5 random images in horizontal order instead of vertical order?
I am using following code in php block of AD management and its working okay.
global $scripturl,$db_prefix,$modSettings,$boardurl;
if(empty($modSettings['gallery_url']))
{
$modSettings['gallery_url'] = $boardurl . '/gallery/';
}
$request = db_query("SELECT thumbfilename,ID_PICTURE
FROM {$db_prefix}gallery_pic
ORDER BY RAND() LIMIT 5", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
{
echo' <center><a href="', $scripturl, '?action=gallery;sa=view;id=', $row['ID_PICTURE'], '"><img src="', $modSettings['gallery_url'] . $row['thumbfilename'] ,'" /></a></center>';
}
mysql_free_result($request);
Logged
Raji
Inline PM Customer
Offline
Posts: 10
Re: Random Image in Block?
«
Reply #112 on:
March 08, 2009, 11:52:44 am »
This code worked for me
Quote
global $scripturl,$db_prefix,$modSettings,$boardurl;
echo'<table cellspacing="0" cellpadding="0" border="0" width="90%"><tr>';
if(empty($modSettings['gallery_url']))
{
$modSettings['gallery_url'] = $boardurl . '/gallery/';
}
$request = db_query("SELECT thumbfilename, ID_CAT, ID_PICTURE FROM {$db_prefix}gallery_pic WHERE ID_CAT = '1' GROUP BY thumbfilename ORDER BY RAND() LIMIT 7", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
while ($row = mysql_fetch_assoc($request))
echo' <td align="center" colspan="3"><a href="', $scripturl, '?action=gallery;sa=view;id=',
$row['ID_PICTURE'], '"><img src="', $modSettings['gallery_url'] .
$row['thumbfilename'] ,'" /></a>';
echo'</td></tr>';
echo'</table></br>';
mysql_free_result($request);
www.baask.com/diwwan
Logged
Pages:
1
...
6
7
[
8
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
SMFHacks.com
-----------------------------
=> News
=> Site Discussion
===> Suggestions
===> Bugs
-----------------------------
SMF Gallery Pro
-----------------------------
=> Announcements
=> Presales
=> Support
===> Bugs
===> Feature Requests
-----------------------------
SMF Store
-----------------------------
=> Announcements
=> Presales
=> Support
===> Guides and Tips
===> Feature Requests
===> Bugs
-----------------------------
SMF Classifieds
-----------------------------
=> Announcements
=> Presales
=> Support
===> Bugs
===> Feature Requests
-----------------------------
Downloads System Pro
-----------------------------
=> Announcements
=> Presales
=> Support
===> Feature Requests
===> Bugs
-----------------------------
Ad Seller Pro
-----------------------------
=> Presales
=> Support
-----------------------------
Menu Editor Pro
-----------------------------
=> Presales Menu Editor Pro
=> Bug Reports
-----------------------------
Inline Personal Messages
-----------------------------
=> Presales
=> Support
=> Bug Reports
-----------------------------
Newsletter Pro
-----------------------------
=> Presales
=> Support
===> Feature Requests
-----------------------------
Badge Awards
-----------------------------
=> Presales
=> Support
-----------------------------
Tweet Topics/FB Post System
-----------------------------
=> Presales
-----------------------------
Social Login Pro
-----------------------------
=> Presales
-----------------------------
SMF Gallery Lite
-----------------------------
=> SMF Gallery Lite
-----------------------------
Modifications/Themes
-----------------------------
=> General SMF Forum
=> Modifications Talk
===> Latest Mods
===> Modification Showcase
=> Theme Talk
===> Theme Showcase
===> Latest Themes
Recent
Code for ultimate Profile
by
Draffi
[
Today
at 03:27:16 pm]
Help me program these awa...
by
SMFHacks
[
Today
at 02:20:35 pm]
Parent and children Badge...
by
Draffi
[
Today
at 02:11:10 pm]
Badge block
by
Draffi
[
Today
at 01:18:58 pm]
[Request] - Award for any...
by
SMFHacks
[
Today
at 12:22:02 am]
Changing the font
by
SMFHacks
[
Today
at 12:20:41 am]
SMF vs PhpBB
by
gibranabahel
[May 19, 2013, 11:13:02 pm]
Upgrade SMF Gallery Pro
by
DTroup
[May 19, 2013, 08:18:27 pm]
sa facebook integration c...
by
murdocklawless
[May 19, 2013, 07:03:27 am]
Feature Requests for SMF ...
by
Secure
[May 16, 2013, 10:13:46 pm]
Random Picture
Donate to SMFHacks.com
Help Support the SMFHacks.com mod making.
Loading...