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
Thanks :D
I'll try it out :up:
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).
Thanks :D
I'll try it out :up:
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
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.
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?
Nope. But it's exactly 100% opposite of what you want. ;)
Change:
if (!$user_info['is_guest'])
To:
if ($user_info['is_guest'])
aaaahhh i see my non-eagle-programmer eyes failed to catch the !
lol thanks :D
Great! I will try, so whats the final code with no errors?
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>';
Thanks! It worked!