* User

Welcome, Guest. Please login or register.
Did you miss your activation email?

12 Mar 10, 00:28:49

Login with username, password and session length

Select language:

* Recent Topics



Donate

Donate for PortaMx !
Your donation is safe and helps support the issues and causes you care most about.

* Stats

  • *Total Members: 1973
  • *Latest: jimpacgr

  • *Total Posts: 9044
  • *Total Topics: 1317
  • *Online Today: 18
  • *Most Online: 157
(27 Aug 09, 03:54:53)
  • *Users: 0
  • *Guests: 12
  • *Spiders: 0
  • *Total: 12

* Themes

*

Author Topic: Blocco immagine random con SMF Gallery  (Read 716 times)

0 Members and 1 Guest are viewing this topic.

Offline russena

  • avolesi.it
  • Newbie
  • *
  • Posts: 41
  • Gender: Male
    • avolesi.it - Il comune di Avola e l'eco dei cittadini avolesi e ri fora
Blocco immagine random con SMF Gallery
« on: 18 Nov 09, 10:56:15 »
Se hai installato SMF Media Gallery di SMF-Media.com di seguito ecco un blocco in php per visualizzare uno o più oggetti a caso prelevato dalla gallery:

Code: [Select]
global $sourcedir, $user_info, $ID_MEMBER, $context, $txt, $galurl, $galurl2, $scripturl, $settings, $db_prefix;

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

   if(loadlanguage('MGallery') == false)
      loadLanguage('MGallery', 'italian');
   $items = getMediaItems(0, 1, 'RAND()');

echo '
<center><table>
<br />
';
   foreach($items as $item)
      echo '

   <td>
   <div align="center" class="smalltext" style=" line-height: 1.4em; border: 1px #000000 solid; 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" alt="" /></a><br />
      ',$txt['mgallery_views'],' : ',$item['views'],' volte<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>
   </td>';

echo '
   </tr>
</table></center>';

se vuoi visualizzare più oggetti/img cambia il numero 1 nel seguente codice:
Code: [Select]
$items = getMediaItems(0, 1, 'RAND()');
www.avolesi.it
Ho sempre pensato che la scuola fosse fatta prima di tutto dagli insegnanti. In fondo chi mi ha salvato dalla scuola se non tre o quattro insegnanti? [Daniel Pennac]

Offline russena

  • avolesi.it
  • Newbie
  • *
  • Posts: 41
  • Gender: Male
    • avolesi.it - Il comune di Avola e l'eco dei cittadini avolesi e ri fora
Re: Blocco immagine random con SMF Gallery
« Reply #1 on: 20 Nov 09, 16:30:51 »
Con il seguente codice si potrà vedere anche lìautore che ha inserito l'oggetto con relativo link al profilo:
Code: [Select]
global $sourcedir, $user_info, $ID_MEMBER, $context, $txt, $galurl, $galurl2, $scripturl, $settings, $db_prefix;

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

   if(loadlanguage('MGallery') == false)
      loadLanguage('MGallery', 'italian');
   $items = getMediaItems(0, 1, 'RAND()');

echo '
<center><table>
<br />
';
   foreach($items as $item)
      echo '

   <td>
   <div align="center" class="smalltext" style=" line-height: 1.4em; border: 1px #000000 solid; 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" alt="" /></a><br />
      ',$txt['mgallery_views'],' : ',$item['views'],' volte<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>
   </td>';

echo '
   </tr>
</table></center>';

tratto dal codice originale: http://portamx.com/index.php/topic,1169.msg6792.html#msg6792
www.avolesi.it
Ho sempre pensato che la scuola fosse fatta prima di tutto dagli insegnanti. In fondo chi mi ha salvato dalla scuola se non tre o quattro insegnanti? [Daniel Pennac]