Twitter SMFHacks Facebook SMFHacks SMFHacks.com
** Home Forum Index Hacks Products Login Register Search
Welcome, Guest. Please login or register.
May 19, 2013, 08:04:19 pm

Login with username, password and session length
Members
Total Members: 10758
Latest: murdocklawless
Stats
Total Posts: 32353
Total Topics: 5475
Online Today: 60
Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Users: 2
Guests: 44
Total: 46
+ 
|-+ 
| |-+ 
| | |-+ 
| | | |-+ 
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: 1 ... 3 4 [5] 6 7 8 Go Down Print
Author Topic: Random Image in Block?  (Read 78795 times)
xface
Inline PM Customer
*****
Offline Offline

Posts: 16


View Profile
« Reply #60 on: October 13, 2006, 10:13:11 am »

I changed up your output codes to this:
Code:
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.
Logged
Jump1979man
Sr. Member
****
Offline Offline

Posts: 274



View Profile WWW
« 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:
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:
ssi_galleryrandom();




Code works great!  Thanks.
Logged

Midwest Motorcycles Forum
http://www.mwmotorcycles.com

Riverway Racing
https://www.riverwayracing.com
Motorcycle parts, gear, and accessories.
Jump1979man
Sr. Member
****
Offline Offline

Posts: 274



View Profile WWW
« 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???
Logged

Midwest Motorcycles Forum
http://www.mwmotorcycles.com

Riverway Racing
https://www.riverwayracing.com
Motorcycle parts, gear, and accessories.
Warbird
Inline PM Customer
*****
Offline Offline

Posts: 5


View Profile
« 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 ?

Logged
Warbird
Inline PM Customer
*****
Offline Offline

Posts: 5


View Profile
« 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
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10988


View Profile
« 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
Logged
Warbird
Inline PM Customer
*****
Offline Offline

Posts: 5


View Profile
« 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.
Logged
Warbird
Inline PM Customer
*****
Offline Offline

Posts: 5


View Profile
« 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
Logged
Warbird
Inline PM Customer
*****
Offline Offline

Posts: 5


View Profile
« 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 » Logged
Hack
Inline PM Customer
*****
Offline Offline

Posts: 1


View Profile
« 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:
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..)
Logged
Protocultura
Inline PM Customer
*****
Offline Offline

Posts: 7


View Profile
« Reply #70 on: November 20, 2006, 09:30:59 am »

Hi, I'm receiving the same error reported a few lines ago.
Code:
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.
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10988


View Profile
« 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?
Logged
Protocultura
Inline PM Customer
*****
Offline Offline

Posts: 7


View Profile
« Reply #72 on: November 20, 2006, 10:02:33 am »

Yep.
SSI.php
Code:
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:
<table width="860" border="0" cellpadding="0" cellspacing="0">

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

<tr>...
Any idea?
Thanks
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10988


View Profile
« 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:
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>
<?
Logged
Protocultura
Inline PM Customer
*****
Offline Offline

Posts: 7


View Profile
« 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!!!
Logged
Pages: 1 ... 3 4 [5] 6 7 8 Go Up Print 
« previous next »
Jump to:  

Recent
[Today at 07:16:11 pm]

[Today at 07:03:27 am]

[May 16, 2013, 10:13:46 pm]

[May 15, 2013, 11:32:14 pm]

[May 15, 2013, 11:31:24 pm]

[May 12, 2013, 09:10:43 am]

[May 10, 2013, 03:49:55 am]

[May 07, 2013, 07:12:40 pm]

[May 07, 2013, 02:37:14 pm]

[May 06, 2013, 10:29:56 pm]
Random Picture
Donate to SMFHacks.com
Help Support the SMFHacks.com mod making.
Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
TinyPortal v0.9.7 © Bloc
SMF and SimpleMachines are registered trademarks of Simple Machines. SMFHacks.com is not affiliated with nor endorsed by Simple Machines.
Page created in 1.374 seconds with 20 queries.