Facebook  Twitter 

SMFHacks.com

+- +-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 12382
Latest: ImportedPotato
New This Month: 1
New This Week: 1
New Today: 0
Stats
Total Posts: 40238
Total Topics: 7088
Most Online Today: 97
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 35
Total: 35

Author Topic: Random Image in Block?  (Read 127639 times)

0 Members and 1 Guest are viewing this topic.

Offline xface

  • Bad Emails DO NOT EMAIL
  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Random Image in Block?
« Reply #60 on: October 13, 2006, 10:13:11 am »
I changed up your output codes to this:
Code: [Select]
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,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">&lt;a href="<?echo $modSettings['gallery_url'].$row['filename']; ?>"&gt;&lt;img src="<?echo $modSettings['gallery_url'].$row['thumbfilename'];?>"&gt;&lt;/a&gt;</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>
<?
}
and it works awesome as well.....
This way the code is easily selected and copied.

Offline Jump1979man

  • Sr. Member
  • ****
  • Posts: 274
    • View Profile
    • Midwest Motorcycles Forum
Re: Random Image in Block?
« Reply #61 on: October 13, 2006, 11:07:34 am »
I'll help everyone out. I modified SMF Hack's code and made it center when it a block.. No biggy.



USE THIS ONE
Code: [Select]
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>'

;}

Put this in a PHP block.

Code: [Select]
ssi_galleryrandom();



Code works great!  Thanks.
Midwest Motorcycles Forum
http://www.mwmotorcycles.com

Riverway Racing
https://www.riverwayracing.com
Motorcycle parts, gear, and accessories.

Offline Jump1979man

  • Sr. Member
  • ****
  • Posts: 274
    • View Profile
    • Midwest Motorcycles Forum
Re: Random Image in Block?
« Reply #62 on: October 13, 2006, 11:08:11 am »
Anyway to have like the first 2 or three comments to show up as well???
Midwest Motorcycles Forum
http://www.mwmotorcycles.com

Riverway Racing
https://www.riverwayracing.com
Motorcycle parts, gear, and accessories.

Offline Warbird

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Random Image in Block?
« Reply #63 on: October 30, 2006, 10:35:25 am »
I did what you guys did but still got a error in this box.

Quote
Parse error: parse error, unexpected $ in /var/www/vhosts/placenholder/subdomains/forums/httpdocs/Sources/Load.php(1718) : eval()'d code(35) : eval()'d code on line 1

What can it be ?


Offline Warbird

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Random Image in Block?
« Reply #64 on: October 30, 2006, 10:40:55 am »
Hmm, ok, got it working now, donīt know why it didnīt worked before, but ok. One more question, is it possible to make a bigger thumbnail size ?

Its 104 x 78, but I would prefer the thumb more around 150 or 160 width, is that possible ?

WarBirD

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15116
    • View Profile
Re: Random Image in Block?
« Reply #65 on: October 30, 2006, 10:48:09 am »
Well you could use html to enlarge the size of the image or if you really want a larger image you would need to change the thumbnail size in Gallery.php
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline Warbird

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Random Image in Block?
« Reply #66 on: October 30, 2006, 11:00:18 am »
Where in the text I put in SSI.PHP would be the place where to make it with HTML. Sry, i am not sure in code and all that.

Offline Warbird

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Random Image in Block?
« Reply #67 on: October 30, 2006, 11:10:13 am »
Ok, since I donīt know where in the SSI.PHP Lines i added, i tried the GALLERY.PHP. There is quite sometimes the values 104 and 78 which I assume is the width and height. Changed them all, but still shows the same size as before. Anything else ?

WarbiRd

Offline Warbird

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Random Image in Block?
« Reply #68 on: October 30, 2006, 11:15:49 am »
Ok, my Browserīs cache played badly on me. But here is the problem if I do it with the changes in GALLERY.PHP, it only creates Thumbs from now on with that Size. All the Images I had before in there are in the old Size. So I would like to have some help where to do the HTML resize values with width="" and height="" in the code I added to the SSI.PHP.

P.S: How to get rid of the LINKING CODES button ?
« Last Edit: October 30, 2006, 11:32:46 am by Warbird »

Offline Hack

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Random Image in Block?
« Reply #69 on: November 11, 2006, 11:02:19 am »
thought I would add my little bit of code to this block section too. All I have basically added is the Images name below each of the pictures thats shown in the block (also added a 'alt' tag for the image)

Code: [Select]
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, title, description
                                FROM {$db_prefix}gallery_pic
                                WHERE ID_CAT NOT LIKE '%7%'
                                ORDER BY RAND() LIMIT 3", __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'] ,'" style="padding-bottom:3px; padding-top:6px" alt="Random Gallery Mini Image" /><br />' . $row['title'] . '<br /></a></center>';
  }
  mysql_free_result($request);
}

Got a feeling I have probably got the 'style' part of the image src thing incorrect, but I am only a beginner with this sort of thing. If you only want certain catagorys showing you will need to exclude them by changing the 'ID_CAT not like' part to exclude the catagory you dont want to be included (in my case it stops the news post images being included as part of the random image display).

Thanks for the block though, makes th site look snazzy. All I want to really add to this now is the ability to make it 'scroll' like you see with the phpnuke blocks.. does anyone know how to do this? (will save me some time if they do..)

Offline Protocultura

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Random Image in Block?
« Reply #70 on: November 20, 2006, 09:30:59 am »
Hi, I'm receiving the same error reported a few lines ago.
Code: [Select]
Fatal error: Call to undefined function: ssi_galleryrandom() in /home/c4dbra/public_html/Sources/Load.php(1708) : eval()'d code on line 427
Somebody knows why?
Thanks.

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15116
    • View Profile
Re: Random Image in Block?
« Reply #71 on: November 20, 2006, 09:45:10 am »
Do you have the ssi_galleryrandom() in SSI.php and are you using an SSI block?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline Protocultura

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Random Image in Block?
« Reply #72 on: November 20, 2006, 10:02:33 am »
Yep.
SSI.php
Code: [Select]
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,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">&lt;a href="<?echo $modSettings['gallery_url'].$row['filename']; ?>"&gt;&lt;img src="<?echo $modSettings['gallery_url'].$row['thumbfilename'];?>"&gt;&lt;/a&gt;</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>
<?
}
?>

index.template.php
Code: [Select]
<table width="860" border="0" cellpadding="0" cellspacing="0">

<tr>
<td>';
ssi_galleryrandom();
echo '</td>
</tr>

<tr>...
Any idea?
Thanks

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 15116
    • View Profile
Re: Random Image in Block?
« Reply #73 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: [Select]
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">&lt;a href="<?echo $modSettings['gallery_url'].$row['filename']; ?>"&gt;&lt;img src="<?echo $modSettings['gallery_url'].$row['thumbfilename'];?>"&gt;&lt;/a&gt;</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>
<?
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline Protocultura

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Random Image in Block?
« Reply #74 on: November 20, 2006, 10:59:16 am »
thanks, works like a charm!
You can see the mod in my site www.c4dbrasil.com
Thanks SMFHacks a priceless piece of code!!!

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
3505 Views
Last post June 18, 2010, 09:18:00 am
by dvera
2 Replies
4255 Views
Last post October 15, 2010, 04:03:02 pm
by Rafferty
1 Replies
2596 Views
Last post October 16, 2016, 12:12:51 pm
by exit
5 Replies
2910 Views
Last post July 12, 2017, 03:45:34 pm
by donk
8 Replies
4784 Views
Last post December 04, 2017, 09:41:20 pm
by Boomslanger

+- Recent Topics

Call to undefined function mysql_num_rows() by SMFHacks
July 30, 2020, 07:45:29 am

Problem with one videosite embedding by Hatshepsut
July 24, 2020, 01:25:08 am

Download System Lite by Rock Lee
June 03, 2020, 07:34:24 pm

Font question by SMFHacks
May 27, 2020, 08:15:26 am

Error message with latest SMF 2.1 Github build by Hatshepsut
May 25, 2020, 01:43:26 am

smfblog not working on 2.0.17 by tech9
May 20, 2020, 01:44:34 pm

Copyright removal by stbc
May 18, 2020, 01:27:57 am

Mod Verified User i can't square the image by Rock Lee
May 07, 2020, 07:56:10 pm

SMF4Mobile 2.0 released for SMF 2.0.x by SMFHacks
May 06, 2020, 12:13:14 pm

SMF Social Login Pro - Discontinued? by Nicole
May 02, 2020, 05:47:04 pm

Powered by EzPortal