TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

February 24, 2024, 02:33:44 AM

Login with username, password and session length
Members
  • Total Members: 3,881
  • Latest: fords8
Stats
  • Total Posts: 195,062
  • Total Topics: 21,208
  • Online today: 49
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 57
  • Total: 57

[Block] SMF Media Gallery Random Picture

Started by Petee, December 14, 2008, 06:02:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dark-Wolf

SMF-Media block code is more clean :)
Instead to use <center> (deprecated and old tag) i've used:
<table style="margin: 0 auto; border: 0;">  ;)

G6Cad

Yes you can exclude everything if you like.
Look in the top of the code, you have the diffrent settings right there.

Dark-Wolf

#42
Quote from: G6 on May 27, 2009, 10:20:39 AM
Yes you can exclude everything if you like.
Look in the top of the code, you have the diffrent settings right there.
My final code is this (only one random image without table):
global $sourcedir, $context, $txt, $galurl, $scripturl, $settings;

require_once($sourcedir . '/Subs-MGallery.php');
loadMGal_Settings();

if (loadlanguage('MGallery') == false)
  loadLanguage('MGallery', 'english');

$items = getMediaItems(0, 1, 'RAND()');

foreach ($items as $item)
  echo '
      <div class="smalltext" style="text-align: center; line-height: 1.4em; border: 0; padding: 5px;">
      <a href="',$galurl,'sa=item;id=',$item['id'],'">',$item['title'],'</a><br />
      <a href="',$galurl,'sa=item;id=',$item['id'],'"><img alt="" src="',$galurl,'sa=media;id=',$item['id'],';thumb" /></a><br />
      ',$txt['mgallery_views'],': ',$item['views'],'<br />
      ',$txt['mgallery_posted_by'],': <a href="',$scripturl,'?action=profile;u=',$item['poster_id'],'">',$item['poster_name'],'</a><br />
      ',$txt['mgallery_in_album'],': <a href="',$galurl,'sa=album;id=',$item['id_album'],'">',$item['album_name'],'</a>
      ',$item['is_new'] ? '<br /><img alt="" src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" border="0" />' : '','
      </div>';
:)

---
One new question: "Can i exclude a specific gallery(ID) to the block"?

jpacs29

#43
// Hi Guys, try this code it will show 5 images without border and thumbnail info on your TP block.... hope you like it :D
______________________________________________________________________


global $sourcedir, $context, $txt, $galurl, $scripturl, $settings;

require_once($sourcedir . '/Subs-MGallery.php');
loadMGal_Settings();

if (loadlanguage('MGallery') == false)
  loadLanguage('MGallery', 'english');

$items = getMediaItems(0, 5, 'rand()');

echo '
<center><table border="0">
  <tr>';

foreach ($items as $item)
  echo '
    <td>
   <div class="smalltext" style="text-align: center; line-height: 1.4em; border: 0px #000000 solid; padding: 5px;">
      <a href="',$galurl,'sa=item;id=',$item['id'],'"></a><br />
      <a href="',$galurl,'sa=item;id=',$item['id'],'"><img alt="" src="',$galurl,'sa=media;id=',$item['id'],';thumb" alt="" /></a><br />

      ',$item['is_new'] ? '<br /><img alt="" src="' . $settings['images_url'] . '/' . $context['user']['language'] . '/new.gif" border="0" />' : '','
      </div>
    </td>';
echo '
  </tr>
</table></center>';

_________________________________________________________________

Freddy

Cool :)   I Didn't know about the getMediaItems function, thanks jpacs.

I'll have to take a better look at mgallery I think...

jpacs29

Quote from: freddy888 on September 05, 2009, 01:42:44 PM
Cool :)   I Didn't know about the getMediaItems function, thanks jpacs.

I'll have to take a better look at mgallery I think...

Welcome freddy...  i was just lucky that when i tweak that codes, i have no problem during the testing but then i had to do trial and error method too :D