Forum Index > Help > Geeklog le CMS New Topic Post Reply
 is it possible to do this.... in Media Gallery?
   
hfd
 28 janvier 2013 - 01:31 (Read 4633 times)  
+----
Newbie

Status: offline


Registered: 10/02/2009
Posts: 12
Hello,

Is it possible to pull the "Last media item that was uploaded by the user " to the static page?

Thanks

 
Profile Email Website
 Quote
Ben
 28 janvier 2013 - 08:25  
AAAAA
Admin

Status: offline


Registered: 18/10/2006
Posts: 128
Yes is it possible. Add this function in your lib-custom.php file

PHP Formatted Code
function mg_lastuploaded($limits=15, $user=0) {
    global $MG_albums, $_TABLES, $_CONF, $_MG_CONF, $_USER, $glversion;

    require_once($_MG_CONF['path_html'] . 'classMedia.php');

    $lastupload = '';
        $lastupload .= '<div id="mg_lastupload"><div margin:20px auto; padding-top:25px;">';

    $sql = "SELECT * FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_user_id={$user} ORDER BY m.media_upload_time DESC LIMIT $limits";
    $result = DB_query($sql,1);
    $nRows = DB_numRows($result);
    for ($x = 0; $x < $nRows; $x++) {

        $row = DB_fetchArray($result);

        if ( $MG_albums[$row['album_id']]->access > 0 ) {
               
                       
            $media = new Media($row,$row['album_id']);
                       
            $media->constructor($row,$row['album_id']);
                       
            // this returns the thumbnail
            $lastupload .= '<div style="line-height:9pt;height:95px;float:left; margin:5px; padding:8px 0px;"><div style="padding:5px; background:#FFF; border-top:1px solid #DDD;border-left:1px solid #DDD;border-right:1px solid #ddd;border-bottom:1px solid #ddd;"><div style="overflow:hidden;width:75px;height:75px;"><a href="' . $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id'] . '">' . $media->displayRawThumb() . '</a></div></div>';
                        if ($row['media_title'] == NULL) {
                        $row['media_title'] = 'Media';
                        }
                        $date = date("d-m-Y",$row['media_upload_time']);
                        $lastupload .='<p align="left" style="font-size: 8px; color: #999; margin-top:5px; padding:0px 0px;"><span style="color:#AAA;">' . $date . '</span></p></div>';
        }
    }
       
        $lastupload .= '<div style="clear:both;"></div></div></div>';
       
    return $lastupload;
}


Then call the function in yout static page :
PHP Formatted Code
echo mg_lastuploaded(30,2);

where 30 is the limit for the number of pictures and 2 is the user uid.

Ben

 
Profile Email Website
 Quote
hfd
 29 janvier 2013 - 01:02  
+----
Newbie

Status: offline


Registered: 10/02/2009
Posts: 12
Ben,

I don't know if i did it wrong but it came out as an error.

Fatal error: Call to undefined function mg_lastuploaded2() in /home/user/privatefolder/geeklogfolder/plugins/staticpages/functions.inc(1559) : eval()'d code on line 1


thanks.

 
Profile Email Website
 Quote
Ben
 29 janvier 2013 - 10:31  
AAAAA
Admin

Status: offline


Registered: 18/10/2006
Posts: 128
Sorry there is a typo. The function is call mg_lastuploaded so you need to echo like this:

PHP Formatted Code
echo mg_lastuploaded(30,2);

I will correct my previous post.

Ben

 
Profile Email Website
 Quote
hfd
 30 janvier 2013 - 04:07  
+----
Newbie

Status: offline


Registered: 10/02/2009
Posts: 12
Hello Brother Ben,

The code you give me here, it work find in the Media Gallery version 1.5.0 and Geeklog v1.4.1. But no the new version of GL v1.8.2 and MG v1.6.X. When I put the code to the static page, it looked for the classMedia.php in Mydomain.com/mediagallery/classMedia.php. I checked there and it looked like the new version of MG has none of the same file.

It is good that Media Gallery can turn this page in to a NewsFeed page.

Thanks.


 
Profile Email Website
 Quote
Ben
 30 janvier 2013 - 11:15  
AAAAA
Admin

Status: offline


Registered: 18/10/2006
Posts: 128
Yes this file was moved to a new location. You need to change the code to:

PHP Formatted Code

function mg_lastuploaded($limits=15, $user=0) {
    global $MG_albums, $_TABLES, $_CONF, $_MG_CONF, $_USER, $glversion;

    require_once($_CONF['path'] . 'plugins/mediagallery/include/classMedia.php');

    $lastupload = '';
        $lastupload .= '<div id="mg_lastupload"><div margin:20px auto; padding-top:25px;">';

    $sql = "SELECT * FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_user_id={$user} ORDER BY m.media_upload_time DESC LIMIT $limits";
    $result = DB_query($sql,1);
    $nRows = DB_numRows($result);
    for ($x = 0; $x < $nRows; $x++) {

        $row = DB_fetchArray($result);

        if ( $MG_albums[$row['album_id']]->access > 0 ) {
               
                       
            $media = new Media($row,$row['album_id']);
                       
            $media->constructor($row,$row['album_id']);
                       
            // this returns the thumbnail
            $lastupload .= '<div style="line-height:9pt;height:95px;float:left; margin:5px; padding:8px 0px;"><div style="padding:5px; background:#FFF; border-top:1px solid #DDD;border-left:1px solid #DDD;border-right:1px solid #ddd;border-bottom:1px solid #ddd;"><div style="overflow:hidden;width:75px;height:75px;"><a href="' . $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id'] . '">' . $media->displayRawThumb() . '</a></div></div>';
                        if ($row['media_title'] == NULL) {
                        $row['media_title'] = 'Media';
                        }
                        $date = date("d-m-Y",$row['media_upload_time']);
                        $lastupload .='<p align="left" style="font-size: 8px; color: #999; margin-top:5px; padding:0px 0px;"><span style="color:#AAA;">' . $date . '</span></p></div>';
        }
    }
       
        $lastupload .= '<div style="clear:both;"></div></div></div>';
       
    return $lastupload;
}


Ben

 
Profile Email Website
 Quote
Ben
 30 janvier 2013 - 11:35  
AAAAA
Admin

Status: offline


Registered: 18/10/2006
Posts: 128
ok it's working now. See demo page.

Please try this code:

PHP Formatted Code

function mg_lastuploaded($limits=15, $user=0) {
   
        global $_TABLES, $_CONF, $_MG_CONF, $_USER, $glversion;

    require_once($_CONF['path'] . 'plugins/mediagallery/include/classMedia.php');

    $lastupload = '';
    $lastupload .= '<div id="mg_lastupload">
                            <div margin:20px auto; padding-top:25px;">'
;

    $sql = "SELECT * FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_user_id={$user} ORDER BY m.media_upload_time DESC LIMIT $limits";
       
    $result = DB_query($sql,1);
    $nRows = DB_numRows($result);

    for ($x = 0; $x < $nRows; $x++) {

        $row = DB_fetchArray($result);
                       
                $media = new Media($row,$row['album_id']);
                                   
                $media->constructor($row,$row['album_id']);
                                   
                // this returns the thumbnail
               
                $lastupload .= '<div style="line-height:9pt;height:95px;float:left; margin:5px; padding:8px 0px;">
                    <div style="padding:5px; background:#FFF; border-top:1px solid #DDD;border-left:1px solid #DDD;border-right:1px solid #ddd;border-bottom:1px solid #ddd;">
                            <div style="overflow:hidden;width:75px;height:75px;">
                                    <a href="'
. $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id'] . '">' . $media->displayRawThumb() . '</a>
                                </div>
                        </div>'
;
               
                $date = date("d-m-Y",$row['media_upload_time']);
                $lastupload .='<p align="left" style="font-size: 8px; color: #999; margin-top:5px; padding:0px 0px;"><span style="color:#AAA;">' . $date . '</span></p></div>';
    }
       
    $lastupload .= '<div style="clear:both;"></div>
                    </div>
                    </div>'
;
       
    return $lastupload;
}


Ben

 
Profile Email Website
 Quote
hfd
 31 janvier 2013 - 01:45  
+----
Newbie

Status: offline


Registered: 10/02/2009
Posts: 12
Quote by: ::Ben

ok it's working now. See demo page.

Please try this code:

PHP Formatted Code

function mg_lastuploaded($limits=15, $user=0) {
    global $_TABLES, $_CONF, $_MG_CONF, $_USER, $glversion;

    require_once($_CONF['path'] . 'plugins/mediagallery/include/classMedia.php');

    $lastupload = '';
        $lastupload .= '<div id="mg_lastupload"><div margin:20px auto; padding-top:25px;">';

    $sql = "SELECT * FROM {$_TABLES['mg_media']} AS m LEFT JOIN {$_TABLES['mg_media_albums']} AS ma ON m.media_id=ma.media_id WHERE m.media_user_id={$user} ORDER BY m.media_upload_time DESC LIMIT $limits";
    $result = DB_query($sql,1);
    $nRows = DB_numRows($result);

    for ($x = 0; $x < $nRows; $x++) {

        $row = DB_fetchArray($result);
                       
                $media = new Media($row,$row['album_id']);
                                   
                $media->constructor($row,$row['album_id']);
                                   
                // this returns the thumbnail
                $lastupload .= '<div style="line-height:9pt;height:95px;float:left; margin:5px; padding:8px 0px;"><div style="padding:5px; background:#FFF; border-top:1px solid #DDD;border-left:1px solid #DDD;border-right:1px solid #ddd;border-bottom:1px solid #ddd;"><div style="overflow:hidden;width:75px;height:75px;"><a href="' . $_MG_CONF['site_url'] . '/media.php?s=' . $row['media_id'] . '">' . $media->displayRawThumb() . '</a></div></div>';
                                        if ($row['media_title'] == NULL) {
                                        $row['media_title'] = 'Media';
                                        }
                                        $date = date("d-m-Y",$row['media_upload_time']);
                                        $lastupload .='<p align="left" style="font-size: 8px; color: #999; margin-top:5px; padding:0px 0px;"><span style="color:#AAA;">' . $date . '</span></p></div>';
    }
       
    $lastupload .= '<div style="clear:both;"></div></div></div>';
       
    return $lastupload;
}


Ben


Hi Brother,

Yes, this code does work. I like using this code on the index page more than what we used for putting in for the MG index page.

Can you tell me why the thumbnail is too small. is it possible to make it bigger?

Thank you so much for helping me as Geeklog User.


 
Profile Email Website
 Quote
Ben
 31 janvier 2013 - 09:10  
AAAAA
Admin

Status: offline


Registered: 18/10/2006
Posts: 128
The size of the thumbnail is set in the classMedia.php file near line 802 and you will also need to twick the html in the above code :

PHP Formatted Code
$tn_height = 100;


Ben

 
Profile Email Website
 Quote
hfd
 01 février 2013 - 04:34  
+----
Newbie

Status: offline


Registered: 10/02/2009
Posts: 12
Hello Brother,

Everything is working as expected. I forget to check your Sphere Plugin. The plugin worked well and as I expected. The only difference is the Forum and Media are showed separately. Its not shown on the same page as I thought it would be.

However I am very happy for your help.

Thanks and God bless you.

(My example photo site can be see at my website bottom below.)

 
Profile Email Website
 Quote
Content generated in: 1,94 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content