SimplePortal

Customization => Blocks and Modifications => Block Requests => Topic started by: crank on March 10, 2009, 03:52:56 AM

Title: New MGallery Snippet
Post by: crank on March 10, 2009, 03:52:56 AM
Hi guys.

I am looking for a snippet to place on PHP block that I could select how many pics to display at a time.
For example on different pages I want different number of pics so I have to add the block several times to different pages.

The current block available only draws one pic unless I am mistaken.

Thanks in advance.
Title: Re: New MGallery Snippet
Post by: Shortie on March 30, 2009, 04:42:31 AM
I have a block on my front page

Here.. (http://graphicsmayhem.com/GMForum/index.php)

Is this the sort of thing

It shows that last addition to the Gallery and then under it there are 15 random images

Easy to mod if you are interested

Shortie
Title: Re: New MGallery Snippet
Post by: Dream12 on March 30, 2009, 08:23:15 AM
That looks really good mate!!

I would be intrested in that.

Is it just code???????

As i cant get my SMF Gallery Block to work so am looking for an alterrtive.
Title: Re: New MGallery Snippet
Post by: crank on March 30, 2009, 10:32:52 AM
I have a block on my front page

Here.. (http://graphicsmayhem.com/GMForum/index.php)

Is this the sort of thing

It shows that last addition to the Gallery and then under it there are 15 random images

Easy to mod if you are interested

Shortie

U are a very talented individual. I went Vbulletin though I could not handle SMF anymore.
Title: Re: New MGallery Snippet
Post by: Shortie on March 30, 2009, 04:41:26 PM
Here is the code

It should work but I am sure some one will be able to tidy it up as I am not very good with PHP

If you use it or mod it show us what you did

Cheers

Shortie

Code: [Select]
global $sourcedir, $context, $txt, $galurl, $scripturl, $settings;



if(!file_exists($sourcedir . '/Subs-MGallery.php'))

{

echo $txt['sp-mgallery_error'];

return false;

}

$parameters[1] = 0;

$limit = empty($parameters[0]) ? 1 : (int) $parameters[0];

$type = empty($parameters[1]) ? 'm.id_media DESC' : 'RAND()';



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

loadMGal_Settings();



loadLanguage('MGallery', sp_languageSelect('MGallery'));



$items = getMediaItems(0, $limit, $type);



echo '
    <hr />
<div style="text-align: center; line-height: 1.4em;">The Latest Gallery Submission</div>
<hr />
<table style="border: 0; margin: 0 auto;">

';



foreach ($items as $item)

  echo '
  <tr>
    <td>

      <div class="smalltext" style="text-align: center; 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 src="', $galurl, 'sa=media;id=', $item['id'], ';preview" alt="" /></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>

    </td>  </tr>';



echo '



</table>';

$parameters[1] = 1;


$limit = empty($parameters[0]) ? 5 : (int) $parameters[0];

$type = empty($parameters[1]) ? 'm.id_media DESC' : 'RAND()';



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

loadMGal_Settings();



loadLanguage('MGallery', sp_languageSelect('MGallery'));



$items = getMediaItems(0, $limit, $type);



echo '
    <hr />
<div style="text-align: center; line-height: 1.4em;">A selection of Random Images from the Gallery</div>
<hr />
<table style="border: 0; margin: 0 auto;">

  <tr style="width:150px; height:150px;">';



foreach ($items as $item)

  echo '

    <td>

      <div class="smalltext" style="text-align: center; line-height: 1.4em; border: 1px #000000 solid; padding: 5px;width:125px;height:160px;">

      <a href="', $galurl, 'sa=item;id=', $item['id'], '">', $item['title'], '</a><br />

      <a href="', $galurl, 'sa=item;id=', $item['id'], '"><img src="', $galurl, 'sa=media;id=', $item['id'], ';thumb" alt="" /></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>

    </td>';



echo '

  </tr>

</table>';
$parameters[1] = 1;


$limit = empty($parameters[0]) ? 5 : (int) $parameters[0];

$type = empty($parameters[1]) ? 'm.id_media DESC' : 'RAND()';



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

loadMGal_Settings();



loadLanguage('MGallery', sp_languageSelect('MGallery'));



$items = getMediaItems(0, $limit, $type);



echo '
<table style="border: 0; margin: 0 auto;">

  <tr style="width:150px; height:150px;">';



foreach ($items as $item)

  echo '

    <td>

      <div class="smalltext" style="text-align: center; line-height: 1.4em; border: 1px #000000 solid; padding: 5px;width:125px;height:160px;">

      <a href="', $galurl, 'sa=item;id=', $item['id'], '">', $item['title'], '</a><br />

      <a href="', $galurl, 'sa=item;id=', $item['id'], '"><img src="', $galurl, 'sa=media;id=', $item['id'], ';thumb" alt="" /></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>

    </td>';



echo '

  </tr>

</table>';
$parameters[1] = 1;


$limit = empty($parameters[0]) ? 5 : (int) $parameters[0];

$type = empty($parameters[1]) ? 'm.id_media DESC' : 'RAND()';



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

loadMGal_Settings();



loadLanguage('MGallery', sp_languageSelect('MGallery'));



$items = getMediaItems(0, $limit, $type);



echo '
<table style="border: 0; margin: 0 auto;">

  <tr>';



foreach ($items as $item)

  echo '

    <td style="width:150; height:150;">

      <div class="smalltext" style="text-align: center; line-height: 1.4em; border: 1px #000000 solid; padding: 5px;width:125px;height:160px;">

      <a href="', $galurl, 'sa=item;id=', $item['id'], '">', $item['title'], '</a><br />

      <a href="', $galurl, 'sa=item;id=', $item['id'], '"><img src="', $galurl, 'sa=media;id=', $item['id'], ';thumb" alt="" /></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>

    </td>';



echo '

  </tr>

</table>';

Title: Re: New MGallery Snippet
Post by: Dream12 on March 30, 2009, 04:57:17 PM
do you have to add the url of the picture mannuely for each one????

And thanks mate!! looks good!!! :D
Title: Re: New MGallery Snippet
Post by: Shortie on March 30, 2009, 06:08:31 PM
Sorry do not quiet follow

The code should be self contained

as it takes the latest gallery image from the DB and the three lines of 5 random images are also generated from the details in the DB so you should not have to add any URL's

One thing to note - it is possible to have two images the same in the 15 random ones but is unlikely and if it does occur again will anyone notice

Shortie
Title: Re: New MGallery Snippet
Post by: Dream12 on March 31, 2009, 09:07:13 AM
Sorry mate!!! but you answered the question billiant :D

But cant seem to get it to work: Get This error up
Fatal error: Call to undefined function: sp_languageselect() in /content/StartupHostPlus/s/w/swampys-swamp.co.uk/web/simplemachine/Sources/SPortal1-1.php(1947) : eval()'d code on line 29

Any ideas???
Title: Re: New MGallery Snippet
Post by: Shortie on March 31, 2009, 11:17:25 AM
Okay

Can you try just this code in a php block

I should just display the latest image

Cheers

Shortie

Also what version of MGallery are you using just in case - I am using 1.5.5 and the GD2 Library but should not make a difference



Code: [Select]
   global $sourcedir, $context, $txt, $galurl, $scripturl, $settings;



   if(!file_exists($sourcedir . '/Subs-MGallery.php'))

   {

      echo $txt['sp-mgallery_error'];

      return false;

   }

$parameters[1] = 0;

   $limit = empty($parameters[0]) ? 1 : (int) $parameters[0];

   $type = empty($parameters[1]) ? 'm.id_media DESC' : 'RAND()';



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

   loadMGal_Settings();

   

   loadLanguage('MGallery', sp_languageSelect('MGallery'));



   $items = getMediaItems(0, $limit, $type);



   echo '
    <hr />
<div style="text-align: center; line-height: 1.4em;">The Latest Gallery Submission</div>
<hr />
<table style="border: 0; margin: 0 auto;">

';



   foreach ($items as $item)

     echo '
  <tr>
    <td>

      <div class="smalltext" style="text-align: center; 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 src="', $galurl, 'sa=media;id=', $item['id'], ';preview" alt="" /></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>

    </td>  </tr>';



   echo '



</table>';


Title: Re: New MGallery Snippet
Post by: Dream12 on April 01, 2009, 07:06:19 AM
Tried That again mate for ya and still get the same problem......................... with the same message.

and yeah i am using SMF 1.5.5 but not the GD2 libery
Title: Re: New MGallery Snippet
Post by: Shortie on April 01, 2009, 07:58:21 AM
Okay I am a little stumped here   :'( :'(

Another question - Does the standard SimplePortal SMF Gallery Block work I know it is not what you are after but if that works then I will have to look deeper in to my code

Shortie
Title: Re: New MGallery Snippet
Post by: Dream12 on April 01, 2009, 08:40:18 AM
see thats the otrher problem i have that doesnt work either.

Its why i wanted to try your code.

have rasied in the english surrpot bit.
SimplePortal 2.3.8 © 2008-2024, SimplePortal