Bienvenue sur Geeklog France, anonyme 27 août 2016 - 06:47


 28 janvier 2013 - 01:31 (Lu 6583 fois)  

Status : hors ligne

hfd

Utilisateur

Newbie
Enregistré: 10/02/2009
Réponses: 12
Localisation:USA
Hello,

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

Thanks

 28 janvier 2013 - 08:25  

Status : hors ligne

Ben

Administrateur

Admin
Enregistré: 18/10/2006
Réponses: 136
Localisation:la rochelle, France
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

 29 janvier 2013 - 01:02  

Status : hors ligne

hfd

Utilisateur

Newbie
Enregistré: 10/02/2009
Réponses: 12
Localisation:USA
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.

 29 janvier 2013 - 10:31  

Status : hors ligne

Ben

Administrateur

Admin
Enregistré: 18/10/2006
Réponses: 136
Localisation:la rochelle, France
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

 30 janvier 2013 - 04:07  

Status : hors ligne

hfd

Utilisateur

Newbie
Enregistré: 10/02/2009
Réponses: 12
Localisation:USA
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.


 30 janvier 2013 - 11:15  

Status : hors ligne

Ben

Administrateur

Admin
Enregistré: 18/10/2006
Réponses: 136
Localisation:la rochelle, France
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

 30 janvier 2013 - 11:35  

Status : hors ligne

Ben

Administrateur

Admin
Enregistré: 18/10/2006
Réponses: 136
Localisation:la rochelle, France
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

 31 janvier 2013 - 01:45  

Status : hors ligne

hfd

Utilisateur

Newbie
Enregistré: 10/02/2009
Réponses: 12
Localisation:USA
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.


 31 janvier 2013 - 09:10  

Status : hors ligne

Ben

Administrateur

Admin
Enregistré: 18/10/2006
Réponses: 136
Localisation:la rochelle, France
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

 01 février 2013 - 04:34  

Status : hors ligne

hfd

Utilisateur

Newbie
Enregistré: 10/02/2009
Réponses: 12
Localisation:USA
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.)

Le fuseau horaire est CEST. Il est maintenant 06:47 .

  • Sujet Normal
  • Sujet important
  • Sujet clos
  • Nouvelle Contribution
  • Nouveau sujet important
  • Nouveau sujet clos
  • Vous pouvez lire ce forum 
  • Les anonymes peuvent dans ce forum 
  • HTML autorisé 
  • Contrôle vocabulaire