TinyPortal

Development => Block Codes => Topic started by: zambo92 on September 01, 2009, 01:23:46 PM

Title: [Block] Recent activity block for SMF Media Gallery
Post by: zambo92 on September 01, 2009, 01:23:46 PM
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
Title: Re: frontpage block
Post by: Zetan on September 01, 2009, 02:09:26 PM
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.
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 02:11:43 PM
this is the gallery i am using :)

SMF Media Gallery 2.0 beta 4
Title: Re: frontpage block
Post by: Zetan on September 01, 2009, 02:31:22 PM
Did you look in the Snippets Board?
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 02:39:17 PM
yes but that code doesnt work
check my site out: hxxp://keishou.net
Title: Re: frontpage block
Post by: Zetan on September 01, 2009, 02:43:27 PM
What sort of address is hxxp://?

I've moved this to Snippet Requests.
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 02:46:45 PM
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.
Title: Re: frontpage block
Post by: Zetan on September 01, 2009, 02:48:31 PM
I still what to know

Quote from: Zetan on September 01, 2009, 02:43:27 PM
What sort of address is hxxp://?


Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 02:48:50 PM
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
Title: Re: frontpage block
Post by: Zetan on September 01, 2009, 02:51:23 PM
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.
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 02:56:06 PM
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
Title: Re: frontpage block
Post by: JPDeni on September 01, 2009, 03:11:03 PM
freddy will work on it for you, since he has the gallery installed. Just give him a little bit of time.
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 03:11:57 PM
ahh ok, no problemo... thank you very much ^_^
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 03:44:52 PM
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..
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 03:50:06 PM
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')
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 03:59:16 PM
OK zambo thanks - I will start working on that now.
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 03:59:44 PM
awesome, thanks very much freddy :D
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 05:43:03 PM
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 :)
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 05:47:06 PM
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 :)
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 05:48:21 PM
and also, instead of 'by' can you change it to 'Added by: ' :D
and make it appear in my main forum too?
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 05:53:30 PM
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.
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 05:55:34 PM
yeah thats what i cant do since i changed it to a php code block
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 06:01:26 PM
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.
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 06:05:32 PM
it doesnt matter... thanks anyway :D
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 06:16:01 PM
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..
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 06:16:44 PM
check it out now, its pretty good i think :D
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 06:17:28 PM
Hehe, yeah I saw...well done mate.   8)
Title: Re: frontpage block
Post by: zambo92 on September 01, 2009, 06:19:02 PM
thanks :D
its all thanks to you dude tyvm ^_^
Title: Re: frontpage block
Post by: Freddy on September 01, 2009, 06:23:39 PM
welcome  ;D Byeee
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: G6Cad on September 01, 2009, 07:12:42 PM
Moved this to Block code and snippets and added the code for this snippet to the first post.
great work freddy888  :up:
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: Freddy on September 01, 2009, 07:20:27 PM
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.
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 01, 2009, 09:41:29 PM
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
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: Freddy on September 01, 2009, 10:06:19 PM
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.
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: JPDeni on September 01, 2009, 10:12:29 PM
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.
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 01, 2009, 10:15:44 PM
where is the change you made?
it doesnt look any different... and if it is, what do i change to alter how many show?
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 01, 2009, 10:18:10 PM
yes i saw the change you made, but can you make it so that the items are lined up horizontally rather than vertically? :P
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: JPDeni on September 01, 2009, 10:44:44 PM
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.
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: 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?
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: JPDeni on September 02, 2009, 12:25:56 AM
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);

Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 02, 2009, 12:27:41 AM
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
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: JPDeni on September 02, 2009, 12:38:15 AM
Sorry. The last character didn't get copied over. It's there now.
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 02, 2009, 12:40:28 AM
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
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: JPDeni on September 02, 2009, 12:42:18 AM

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);
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 02, 2009, 12:42:48 AM
and also, is there a way to put a border around them individually so they dont look like they're merging together? xD
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: JPDeni on September 02, 2009, 12:44:34 AM

<table border=1>

Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 02, 2009, 12:46:03 AM
where do i put that?
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: JPDeni on September 02, 2009, 12:51:39 AM
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>';

Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: zambo92 on September 02, 2009, 12:58:18 AM
thank you very much for your help ^_^
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: 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!
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: G6Cad on September 02, 2009, 05:48:06 AM
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 :)
Title: Re: [Block] Frontpage block for SMF Media Gallery Images
Post by: Freddy on September 02, 2009, 11:48:18 AM
 ;D Well done and well handled JP, I knew you would like doing that  ;)
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: Silver Knight on December 06, 2009, 08:03:23 PM
Where do i insert it?
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: Freddy on December 06, 2009, 08:06:42 PM
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.
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: jdvarner on December 08, 2009, 01:40:09 AM
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!
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: jdvarner on April 14, 2010, 05:50:35 PM
Since SMF Gallery is now AEVA... can someone help me code this block to work with AEVA. Thank you very much.
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: Freddy on April 18, 2010, 08:52:11 PM
jdvarner,

Do you still need help with this ?
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: jdvarner on April 19, 2010, 05:14:28 AM
nah, im good freddy. Thanks.
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: Blue Steel on April 19, 2010, 05:18:12 AM
I've written a block for Aeva here http://www.tinyportal.net/index.php?topic=32496.msg261167;topicseen#new
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: Freddy on April 19, 2010, 01:12:53 PM
Cool and cool  8)
Title: Re: [Block] Recent activity block for SMF Media Gallery
Post by: Mick on April 19, 2010, 01:29:20 PM
It would be cool if the blocks didnt have a frame and ability to remove the category, name, views, etc.