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

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,966
  • Latest: safir45
Stats
  • Total Posts: 195,985
  • Total Topics: 21,321
  • Online today: 781
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 366
  • Total: 366

Random Image for SMF Gallery Mod

Started by deniz, October 27, 2006, 02:41:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jacortina

Quote from: kran1um on October 28, 2006, 03:37:18 PM
Great! I will try, so whats the final code with no errors?

That depends (sorry, but it's true).

Do you want to put the random image function in your SSI (do you plan on multiple occurrences of calling it or calling it from you site, but outside the TP/Forum structure)?

Do you want to display the extra links to guests or not?

If modifying SSI, look at first post in this thread for what you have to do to accomplish that.

Then create a phpblock with this code:
global $scripturl, $user_info;

ssi_galleryrandom();

if ($user_info['is_guest']) {
echo 'Please register so you can add your pics to the gallery';
}
else
{
echo '<center>
<br>
<a href="',$scripturl,'?action=gallery">Show Gallery</a>
<br>
<a href="',$scripturl,'?action=gallery;sa=add;cat=1">Add Picture</a>
</center>';
}


If you don't want to modify SSI.php, replace the single line:
ssi_galleryrandom();
in the above with the actual contents of the function:

global $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 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>';

kran1um


This website is proudly hosted on Crocweb Cloud Website Hosting.