Quote from: Smoothbrain on December 09, 2008, 07:22:42 PM
Hi all, I have a site that I run SMF Gallery Lite and I love this block snippet and I have another site where I am trying out SMF Media Gallery as it has a few more features I like and I was wondering if anyone has or knows how to modify this block code so that it will work for SMG. Thanks heaps in advance. You guys rule!
I tweaked the code I found on the SMF forums for a different portal block and came up with the code below to work with my site using SMF Media Gallery.
PHPBOX:
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', 'english');
$request = db_query("
SELECT m.id_media, m.id_member, IFNULL(mem.realName, m.member_name) AS member_name, m.id_thumb, m.title, m.description, m.views, m.rating, m.voters,
a.id_album, a.name, IFNULL(lm.time, 0) < m.log_last_access_time AS is_new, m.time_added, m.type
FROM {$db_prefix}mgallery_media AS m
INNER JOIN {$db_prefix}mgallery_albums AS a ON (a.id_album = m.album_id)
LEFT JOIN {$db_prefix}members AS mem ON (mem.ID_MEMBER = m.id_member)
LEFT JOIN {$db_prefix}mgallery_log_media AS lm ON (lm.id_member = $ID_MEMBER AND lm.id_media = m.id_media)
WHERE $user_info[mgallery_query_see_album]
AND m.approved = 1
ORDER BY RAND()
LIMIT 1", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request)) {
$item = array(
'id' => $row['id_media'],
'id_album' => $row['id_album'],
'album_name' => $row['name'],
'item_title' => $row['title'],
'member_name' => $row['member_name'],
'member_id' => $row['id_member'],
'rating' => $row['voters'] != 0 ? ($row['rating']/$row['voters']) : 0,
'voters' => $row['voters'],
'id_thumb' => $row['type'] == 'embed' ? 2 : $row['id_thumb'],
'desc' => $row['description'],
'time_added' => $row['time_added'],
'is_new' => !empty($row['is_new']) && !$user_info['is_guest'],
'views' => $row['views']
);
}
mysql_free_result($request);
echo '
<div class="smalltext" style="text-align: center; line-height: 1.4em; padding: 5px;">
<a href="',$galurl,'sa=item;id=',$item['id'],'">',$item['item_title'],'</a><br /><br />
<a href="',$galurl,'sa=item;id=',$item['id'],'"><img src="',$galurl,'sa=media;id=',$item['id'],';thumb" alt="" /></a><br /><br />
',$txt['mgallery_posted_by'],': <a href="',$scripturl,'?action=profile;u=',$item['member_id'],'">',$item['member_name'],'</a><br />
',$txt['mgallery_in_album'],': <a href="',$galurl,'sa=album;id=',$item['id_album'],'">',$item['album_name'],'</a>
',$item['is_new'] ? '<br />' : '','
</div>';
Below is another version that gives a similar output that I found at the smf-media site.
2, 'rand()'); this part of the code says to pull 2 random pictures. Change it to suit your needs.
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, 2, '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: 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'],'<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>';
excellent block, but is there any chance the thumbnails would be bigger?
When a user uploads an image, a thumbnail is created based on the max width and/or max height you defined in the Admin Panel for SMG. The default is 120, I believe. The block just pulls up that pre-existing thumbnail.
Fabulous! I love it. Thankyou :up:
Perfect!!! worked great. thanks
thank you for this, works a treat!!!
Thanks for this excellent code. I put it in the front block and it worked!! :up:
One question I have though is, are the images suppose to scroll?
No, the code does not have any scrolling option in it. If you want scrolling you need to add the marquee tag to it. Google is your friend if you want to know more about the marquee tag.
Thanks for the response IchBin.
Will look it up.
Sure, need any help with it feel free to post your code and we'll take a look.
Hi IchBin,
Perhaps Marquee tag was not the right choice of words. More like a slide show with a time delay.
I found the code here (http://www.php.net/manual/de/function.harupage-setslideshow.php) but how do I put it in the code above to make it work?
bool HaruPage::setSlideShow ( int $type , float $disp_time , float $trans_time )
Thanks.
There is a ton more code than that for a slideshow. I do believe that Dragoon was working on a slideshow code for it not to long ago. You should probably check with him on his site to see if he has anything he can share.
Thanks IchBin. Dragooon does have a Add on SlideShow but I have to pay for that addon. I might just purchase it.
Thanks once again.
Regards.
thank you very much for this. this is exactly what i've been looking for, awesome work :)
great block, congrats.
could some stuff be added so that it doesn't look so poor? i mean it could also show the date and time of the item's posting, the number of views and comments, dimensions and description etc.there could be a choice of whether all these things will appear or not. wouldn't that be a good idea?
Offcourse :) Just go ahead and add in what you think would be great for this snippet to suit your needs ;)
lol i wish i could. that was just a thought, didn't mean anything bad or offensive (if that's what it came out like).
Thank is perfect! :)
Only a small error with a double alt attribute:
From:
<img alt="" src="',$galurl,'sa=media;id=',$item['id'],';thumb" alt="" />
To:
<img src="',$galurl,'sa=media;id=',$item['id'],';thumb" alt="" /> ;)
What can I do with this message?
I put the code on a PHP block and selected the upper block for it and this is what I got.
Fatal error: require_once() [function.require]: Failed opening required '/home7/armyride/public_html/mmp/Sources/Subs-MGallery.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home7/armyride/public_html/mmp/Sources/Load.php(1745) : eval()'d code(48) : eval()'d code on line 3
Do you have the media gallery installed?
Yes, I have media gallery lite installed
Does the file that is in your error, exist in your Sources Directory?
public_html/mmp/Sources/Subs-MGallery.php'
I am missing that file no it is not in the directory.
The load.php is in there but the Subs-Mgallery.php isn't.
What should I check for?
Have you installed the package ? That file is included in the package. it's not a part of TP
Should I uninstall the gallery and re-install it again?
This block is for Dragoons MEDIA gallery, not for SMF gallery, you need to have the MEDIA gallery installed for this to work,
What gallery do you have installed ?
Hi Everyone,
Just wondering what I would need to edit in this code to have more than one image showing? And also what to remove if I just want the pictures to show no data..?
Have tried a few things but it ended up removing the picture as well lol
Thank you!
Quote from: G6 on March 06, 2009, 11:42:36 AM
This block is for Dragoons MEDIA gallery, not for SMF gallery, you need to have the MEDIA gallery installed for this to work,
What gallery do you have installed ?
Yes I came to figure that out myself. I already installed the dragoon version and got rid of the smf lite.
I will be trying it out shortly. Lets see.
Hey also got a question for you but I think it will be more appropiate to ask via PM
It worked.
Thanks for the support. I appreciate it very much. Being a newbie sucks. :2funny:
We are all newbies at a lot of things in our life, glad you got it sorted :up: :)
Now going back to that PM?................. should I send it?
Also as Bec mentioned, is it possible to get the code to post three pics instead of one? If not it is ok with me I am very pleased with just being able to see one.
Here is a block they posted over at the smf-media site.
2, 'rand()'); this part of the code says to pull 2 random pictures. Change it to suit your needs.
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, 2, '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: 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'],'<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>';
Ok one more thing.
Do you guys know how to take away the outline from the thumbnail?
The first code had a clean picture and the one with multiple pictures puts a rather ugly outline to the thumbnail.
Thanks
Remove border: 1px #000000 solid;
do you have any idea how to display a gallery slideshow in a block code? i know you have to purchase the slideshow code for smf media gallery which I have done, but I was under the impression the slideshow when purchased gave you this effect only to find out i was mistaken and it does not do that at all. I would love it if there was a way to actually display the slideshow in a block.
You would be best asking that over at http://smf-media.com
Quote from: NenaGb on April 21, 2009, 05:54:38 AM
do you have any idea how to display a gallery slideshow in a block code? i know you have to purchase the slideshow code for smf media gallery which I have done, but I was under the impression the slideshow when purchased gave you this effect only to find out i was mistaken and it does not do that at all. I would love it if there was a way to actually display the slideshow in a block.
Quote from: Lesmondâ„¢ on April 21, 2009, 07:03:19 AM
You would be best asking that over at http://smf-media.com
Quote from: NenaGb on April 21, 2009, 05:54:38 AM
do you have any idea how to display a gallery slideshow in a block code? i know you have to purchase the slideshow code for smf media gallery which I have done, but I was under the impression the slideshow when purchased gave you this effect only to find out i was mistaken and it does not do that at all. I would love it if there was a way to actually display the slideshow in a block.
already did and was told he was not interested in looking into it any further at this time. i was a bit disappointed because naturally with a slideshow you would want to be able to feature it on a page or post or w/in a block but that is not an option they offer to work on at time time. :)
nice job. ive been looking for this for a while.
can this block be changed to show pictures from one album only?
To do that I would try changing the url in the script to the url of the album you want... ;) just a guess, I haven't tried that.
Nice block, just installed and it works great! See it here if you want a demo. (http://planetdescent.net) (no, not the picture of the day block, scroll down... :coolsmiley: )
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;"> ;)
Yes you can exclude everything if you like.
Look in the top of the code, you have the diffrent settings right there.
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"?
// 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>';
_________________________________________________________________
Cool :) I Didn't know about the getMediaItems function, thanks jpacs.
I'll have to take a better look at mgallery I think...
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