collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 400
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: New MGallery Snippet  (Read 8346 times)

0 Members and 1 Guest are viewing this topic.

Offline crank

  • Semi Newbie
  • *
  • Posts: 10
    • Webmasters Trade
New MGallery Snippet
« 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.

Offline Shortie

  • Semi Newbie
  • *
  • Posts: 21
  • The Art OF Graphics
    • Graphics Mayhem
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: New MGallery Snippet
« Reply #1 on: March 30, 2009, 04:42:31 AM »
I have a block on my front page

Here..

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

Offline Dream12

  • Semi Newbie
  • *
  • Posts: 27
  • SMF Version: 2 RC1
  • SP Version: 2.2
Re: New MGallery Snippet
« Reply #2 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.

Offline crank

  • Semi Newbie
  • *
  • Posts: 10
    • Webmasters Trade
Re: New MGallery Snippet
« Reply #3 on: March 30, 2009, 10:32:52 AM »
I have a block on my front page

Here..

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.

Offline Shortie

  • Semi Newbie
  • *
  • Posts: 21
  • The Art OF Graphics
    • Graphics Mayhem
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: New MGallery Snippet
« Reply #4 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>';


Offline Dream12

  • Semi Newbie
  • *
  • Posts: 27
  • SMF Version: 2 RC1
  • SP Version: 2.2
Re: New MGallery Snippet
« Reply #5 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

Offline Shortie

  • Semi Newbie
  • *
  • Posts: 21
  • The Art OF Graphics
    • Graphics Mayhem
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: New MGallery Snippet
« Reply #6 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

Offline Dream12

  • Semi Newbie
  • *
  • Posts: 27
  • SMF Version: 2 RC1
  • SP Version: 2.2
Re: New MGallery Snippet
« Reply #7 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???

Offline Shortie

  • Semi Newbie
  • *
  • Posts: 21
  • The Art OF Graphics
    • Graphics Mayhem
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: New MGallery Snippet
« Reply #8 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>';



Offline Dream12

  • Semi Newbie
  • *
  • Posts: 27
  • SMF Version: 2 RC1
  • SP Version: 2.2
Re: New MGallery Snippet
« Reply #9 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

Offline Shortie

  • Semi Newbie
  • *
  • Posts: 21
  • The Art OF Graphics
    • Graphics Mayhem
  • SMF Version: 2 RC2
  • SP Version: 2.3.1
Re: New MGallery Snippet
« Reply #10 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

Offline Dream12

  • Semi Newbie
  • *
  • Posts: 27
  • SMF Version: 2 RC1
  • SP Version: 2.2
Re: New MGallery Snippet
« Reply #11 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.