CODE made by freddy888 added here to first post.
This initial code will provide the most recent thumbnail and details of the latest entry in mgallery. It is most suitable for a side block in this form. This will also work with other media such as mp3 as it uses the inbuilt thumbnails.
If you want a bigger block with more than one recent item then jump ahead to where JPDeni has modified the initial code here... (http://www.tinyportal.net/index.php/topic,30738.msg245448.html#msg245448) which will show as many items as you want horizontally.
global $scripturl, $db_prefix;
// Grab the media details..
$request = db_query("
SELECT n.name, m.id_media, m.id_member, m.title, m.album_id, m.member_name, m.views
FROM {$db_prefix}mgallery_media m
INNER JOIN {$db_prefix}mgallery_albums n ON m.album_id = n.id_album
WHERE m.approved = 1
ORDER BY m.time_added DESC LIMIT 1", __FILE__,__LINE__);
$row = mysql_fetch_assoc($request);
// Output the item..
echo '
<div style="text-align:center">
<p style="margin:0px">
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '">' , $row['title'] , '</a><br />
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '"><img alt="" src="' , $scripturl . '?action=mgallery;sa=media;id=' , $row['id_media'] , ';thumb" /></a><br />
In : <a href="' , $scripturl , '?action=mgallery;sa=album;id=' , $row['album_id'] , '">' , $row['name'] , '</a><br />
Added by : <a href="' , $scripturl , '?action=profile;u=' , $row['id_member'] , '">' , $row['member_name'] , '</a><br />
' , $row['views'] , ($row['views'] == 1 ? ' view' : ' views') , '
</p>
</div>
';
mysql_free_result($request);
Let me know how you get on :)
---------------------------------------------------------------------------------------------------------------------------------------------
hey guys, i added tp to my forums and its really awesome... however, i made a block at the top of the page, and im trying to make it so that whenever somebody adds something new to my gallery (online anime streaming done there), it'll show it in that block.... how can i do that?
my site is hxxp://keishou.net
Hi zambo92, welcome to TinyPortal. Before we can offer any advice, we need you to read the and follow Posting Guidelines.html (http://www.tinyportal.net/index.php/topic,581).
It would also help if you told us what gallery you are using.
There is a Random Gallery block in the Block Code Snippets board:
http://www.tinyportal.net/index.php/board,46.0.html
Lastly, if you are using a gallery we are unfamiliar with, we need to see the code and any other information.
this is the gallery i am using :)
SMF Media Gallery 2.0 beta 4
Did you look in the Snippets Board?
yes but that code doesnt work
check my site out: hxxp://keishou.net
What sort of address is hxxp://?
I've moved this to Snippet Requests.
I can take a look at this....got visitors in a little while, so don't expect a sudden solution, this needs to be figured out from scratch. But I am a little familiar with mgallery and have it on a test site.
Like Zetan says you really need to provide more information.
I still what to know
Quote from: Zetan on September 01, 2009, 02:43:27 PM
What sort of address is hxxp://?
its http but i thought thats how it was supposed to be said on here :$
anyway, what kind of information do you need coz i can supply you with it :)
my website is http://keishou.net
Quote from: zambo92 on September 01, 2009, 02:48:50 PM
its http but i thought thats how it was supposed to be said on here :$
Why would you think that? Never mind. Carry on.
sorry... anyway, can you guys please help me? :)
and i hope you know what im trying to ask of you guys to help me with
freddy will work on it for you, since he has the gallery installed. Just give him a little bit of time.
ahh ok, no problemo... thank you very much ^_^
Thanks JP :)
Hi zambo,
Ok just tell me for now what you want to display in this block.
You will of course want a thumbnail...do you also want :
1) The title ?
2) The member name of who submitted it ?
3) Do you want this to link to the item in the gallery too ?
4) Anything else ?
That should do for now..
yes, a thumbnail, title, views, name of person who submitted it, and what album its from. (so if it were a one piece episode, it'd say 'One Piece')
OK zambo thanks - I will start working on that now.
awesome, thanks very much freddy :D
OK this seems to work, I've tested it with various media and it seems OK :
global $scripturl, $db_prefix;
$limit = 5; // Set how many you want to display here
// Grab the media details..
$request = db_query("
SELECT n.name, m.id_media, m.id_member, m.title, m.album_id, m.member_name, m.views
FROM {$db_prefix}mgallery_media m
INNER JOIN {$db_prefix}mgallery_albums n ON m.album_id = n.id_album
WHERE m.approved = 1
ORDER BY m.time_added DESC LIMIT $limit", __FILE__,__LINE__);
while ($row = mysql_fetch_assoc($request)) {
// Output the item..
echo '
<div style="text-align:center">
<p style="margin:0px">
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '">' , $row['title'] , '</a><br />
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '"><img alt="" src="' , $scripturl . '?action=mgallery;sa=media;id=' , $row['id_media'] , ';thumb" /></a><br />
In : <a href="' , $scripturl , '?action=mgallery;sa=album;id=' , $row['album_id'] , '">' , $row['name'] , '</a><br />
Added by : <a href="' , $scripturl , '?action=profile;u=' , $row['id_member'] , '">' , $row['member_name'] , '</a><br />
' , $row['views'] , ($row['views'] == 1 ? ' view' : ' views') , '
</p>
</div>
';
}
mysql_free_result($request);
Let me know how you get on :)
could you make it so that when it says 'In: Basquash' rather than 'In Basquash' ?
and the same for the person who added it, please :)
and also, instead of 'by' can you change it to 'Added by: ' :D
and make it appear in my main forum too?
No problem...I altered the code above...
I thought you would be using it in a side block.
To have it appear in the main forum you will need to adjust your block display settings.
yeah thats what i cant do since i changed it to a php code block
Quoteyeah thats what i cant do since i changed it to a php code block
You lost me there I am afraid..
You could set up a block to appear in the main forum too....
Or I suggest you use it as a side block, then you can have it appear all over your site.
it doesnt matter... thanks anyway :D
LOL okay zamboo...
You could have also put it in an upper panel block...
Edit : I see you got it working :)
Good luck with your site, it's looking good..
check it out now, its pretty good i think :D
Hehe, yeah I saw...well done mate. 8)
thanks :D
its all thanks to you dude tyvm ^_^
welcome ;D Byeee
Moved this to Block code and snippets and added the code for this snippet to the first post.
great work freddy888 :up:
Thanks G6 :)
I will just add that this will work with other media as well, not just images. Probably the best use of it is in a side block as it uses thumbnails.
hey guys... i tried that code, but it only shows one of the things that are added, however could you make it so that it'll show the last 5 items that were added? because it just looks weird when there's one :S
I'll pick this up again tomorrow as it's late here now. Unless anyone else wants to take it up that is...fine by me.
It was just a little change so I went ahead and made it. I altered freddy's code to make the number of items to be selectable. You can set it from 1 to 100 or anywhere in between.
where is the change you made?
it doesnt look any different... and if it is, what do i change to alter how many show?
yes i saw the change you made, but can you make it so that the items are lined up horizontally rather than vertically? :P
Maybe you should decide what it is that you want -- the whole package -- so that whoever writes the code can make all the changes at once.
well i know what i want, the code you changed was what i wanted however it caused them to line up vertically when i wanted them horizontally :P
could you just fix that please?
Okay.
global $scripturl, $db_prefix;
$limit = 5; // Set how many you want to display here
// Grab the media details..
$request = db_query("
SELECT n.name, m.id_media, m.id_member, m.title, m.album_id, m.member_name, m.views
FROM {$db_prefix}mgallery_media m
INNER JOIN {$db_prefix}mgallery_albums n ON m.album_id = n.id_album
WHERE m.approved = 1
ORDER BY m.time_added DESC LIMIT $limit", __FILE__,__LINE__);
echo '<table><tr>';
while ($row = mysql_fetch_assoc($request)) {
// Output the item..
echo '
<td style="text-align:center">
<p style="margin:0px">
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '">' , $row['title'] , '</a><br />
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '"><img alt="" src="' , $scripturl . '?action=mgallery;sa=media;id=' , $row['id_media'] , ';thumb" /></a><br />
In : <a href="' , $scripturl , '?action=mgallery;sa=album;id=' , $row['album_id'] , '">' , $row['name'] , '</a><br />
Added by : <a href="' , $scripturl , '?action=profile;u=' , $row['id_member'] , '">' , $row['member_name'] , '</a><br />
' , $row['views'] , ($row['views'] == 1 ? ' view' : ' views') , '
</p>
</td>
';
}
echo '</tr></table>';
mysql_free_result($request);
it came up with a syntax error when i inserted that
Parse error: syntax error, unexpected $end in /home/keisunet/public_html/Sources/Load.php(1754) : eval()'d code(48) : eval()'d code on line 30
Sorry. The last character didn't get copied over. It's there now.
thats awesome, thank you very much, just one more thing, i would like to center that, so they'd be in the middle rather than on the left side of my page :P
global $scripturl, $db_prefix;
$limit = 5; // Set how many you want to display here
// Grab the media details..
$request = db_query("
SELECT n.name, m.id_media, m.id_member, m.title, m.album_id, m.member_name, m.views
FROM {$db_prefix}mgallery_media m
INNER JOIN {$db_prefix}mgallery_albums n ON m.album_id = n.id_album
WHERE m.approved = 1
ORDER BY m.time_added DESC LIMIT $limit", __FILE__,__LINE__);
echo '<center><table><tr>';
while ($row = mysql_fetch_assoc($request)) {
// Output the item..
echo '
<td style="text-align:center">
<p style="margin:0px">
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '">' , $row['title'] , '</a><br />
<a href="' , $scripturl , '?action=mgallery;sa=item;id=' , $row['id_media'] , '"><img alt="" src="' , $scripturl . '?action=mgallery;sa=media;id=' , $row['id_media'] , ';thumb" /></a><br />
In : <a href="' , $scripturl , '?action=mgallery;sa=album;id=' , $row['album_id'] , '">' , $row['name'] , '</a><br />
Added by : <a href="' , $scripturl , '?action=profile;u=' , $row['id_member'] , '">' , $row['member_name'] , '</a><br />
' , $row['views'] , ($row['views'] == 1 ? ' view' : ' views') , '
</p>
</td>
';
}
echo '</tr></table></center>';
mysql_free_result($request);
and also, is there a way to put a border around them individually so they dont look like they're merging together? xD
<table border=1>
where do i put that?
There are patterns in the code if you just look for them, but rather than have 10 more posts about this, I'll spell it out.
Replace
echo '<center><table><tr>';
with
echo '<center><table border=1><tr>';
thank you very much for your help ^_^
Quote from: zambo92 on September 01, 2009, 10:46:24 PM
well i know what i want, the code you changed was what i wanted however it caused them to line up vertically when i wanted them horizontally :P
could you just fix that please?
10 posts later.... lmao!
Quote from: IchBinâ„¢ on September 02, 2009, 05:25:15 AM
Quote from: zambo92 on September 01, 2009, 10:46:24 PM
well i know what i want, the code you changed was what i wanted however it caused them to line up vertically when i wanted them horizontally :P
could you just fix that please?
10 posts later.... lmao!
My exact thought to..
Awsome tolerance JP Deni, a big rose for you to day :)
;D Well done and well handled JP, I knew you would like doing that ;)
Where do i insert it?
Well it's a block code - so you need to put it in a block...and it needs to be a PHP block.
If you are unfamiliar with TP I suggest you take a look at the documentation.
JP great work. While it may of taken long to pan this one out, it sure is a very useful block and code. Thanks. I dont think its just patience. I think you like to help on this board. Thank You!
Since SMF Gallery is now AEVA... can someone help me code this block to work with AEVA. Thank you very much.
jdvarner,
Do you still need help with this ?
nah, im good freddy. Thanks.
I've written a block for Aeva here http://www.tinyportal.net/index.php?topic=32496.msg261167;topicseen#new
Cool and cool 8)
It would be cool if the blocks didnt have a frame and ability to remove the category, name, views, etc.