Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4255
Latest: andreios
New This Month: 3
New This Week: 1
New Today: 0
Stats
Total Posts: 43259
Total Topics: 7518
Most Online Today: 177
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 179
Total: 179

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

0 Members and 1 Guest are viewing this topic.

Offline xface

  • Bad Emails DO NOT EMAIL
  • Member
  • *
  • 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

  • Member
  • *
  • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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

  • Member
  • *
  • 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

  • Member
  • *
  • 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

  • Member
  • *
  • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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: 16436
    • 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

  • Member
  • *
  • 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
6064 Views
Last post June 18, 2010, 09:18:00 am
by dvera
2 Replies
9266 Views
Last post October 15, 2010, 04:03:02 pm
by Rafferty
1 Replies
5380 Views
Last post October 16, 2016, 12:12:51 pm
by exit
5 Replies
5327 Views
Last post July 12, 2017, 03:45:34 pm
by donk
8 Replies
6985 Views
Last post December 04, 2017, 09:41:20 pm
by Boomslanger

+- Recent Topics

No thumbnails on new uploads by SMFHacks
March 27, 2024, 02:10:41 pm

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

an idea for new mod (( content type with different display )) by SMFHacks
February 27, 2024, 01:36:27 pm

[Mod] RSS Feed Poster by SMFHacks
February 27, 2024, 11:57:18 am

find duplicate pictures by fvlog19
February 14, 2024, 02:22:40 pm

Error uploading video. by SMFHacks
February 08, 2024, 02:04:16 pm

Gallery icon as last added image by fvlog19
February 01, 2024, 01:04:56 pm

Powered by EzPortal