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: 370
  • Total: 370

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.

deniz

add fallowing code before "?>" in ssi.php

function ssi_galleryrandom()
{
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 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>'

;}


and add a php block:

ssi_galleryrandom();
echo '<center>
<br>
<a href="http://www.yoursite.com/forum/index.php?action=gallery">Show Gallery</a>
<br>
<a href="http://www.yoursite.com/forum/index.php?action=gallery;sa=add;cat=1">Add Picture</a>
</center>';



change "yoursite.com/forum" depends on your site..

demo : http://www.sifirforum.com/forum/index.php  (right panel)

quote from: http://www.smfhacks.com/index.php/topic,125.60.html

akulion


jacortina

Quote from: deniz on October 27, 2006, 02:41:30 PM
ssi_galleryrandom();
echo '<center>
<br>
<a href="http://www.yoursite.com/forum/index.php?action=gallery">Show Gallery</a>
<br>
<a href="http://www.yoursite.com/forum/index.php?action=gallery;sa=add;cat=1">Add Picture</a>
</center>';



change "yoursite.com/forum" depends on your site..

global $scripturl;
ssi_galleryrandom();
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>';


Or let the php do it for you.  ;)

Note that if this is the only place you're going to display a random image, you can skip modifying the SSI.php and just replace the ssi_galleryrandom() call in the block with the code from the function itself (no FTP'ing, no problems with redo-ing the change at the next upgrade).

akulion


akulion

hey could one of u guys add a "condition check" for the links for gallery and add a pic links?

So that they only appear to members instead of everyone?

that would make the code complete in my view :D

jacortina

global $scripturl, $user_info;
ssi_galleryrandom();
if (!$user_info['is_guest']) {
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>';
}


Don't know what you mean by "add a pic links". As I read the code, the thumbnail is a link to the full picture Gallery display.

akulion

oh no i meant that :

if (!$user_info['is_guest']) {
echo '<center>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>';
}


is that correct?

jacortina

Nope. But it's exactly 100% opposite of what you want. ;)

Change:
if (!$user_info['is_guest'])

To:
if ($user_info['is_guest'])

akulion

aaaahhh i see my non-eagle-programmer eyes failed to catch the !

lol thanks :D

kran1um

Great! I will try, so whats the final code with no errors?

This website is proudly hosted on Crocweb Cloud Website Hosting.