forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: dreams83 on June 18, 2007, 01:25:12 am

Title: Last viewed within 6 hours only
Post by: dreams83 on June 18, 2007, 01:25:12 am
Code: [Select]
case 'last6': // Last viewed pictures in the last 6 hours
                if ($META_ALBUM_SET && $CURRENT_CAT_NAME) {
                        $album_name = $lang_meta_album_names['last6'].' - '. $CURRENT_CAT_NAME;
                } else {
                        $album_name = $lang_meta_album_names['last6'];
                }
$last24 = time() - 21600;
                $query ="SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE (approved = 'YES' AND hits > 0 AND UNIX_TIMESTAMP(mtime) > $last24) $META_ALBUM_SET $keyword";

                $result = cpg_db_query($query);
                $nbEnr = mysql_fetch_array($result);
                $count = $nbEnr[0];
                mysql_free_result($result);

                //if($select_columns != '*') $select_columns .= ', hits, aid, filename, owner_id, owner_name';
                $select_columns = '*'; //allows building any data into any thumbnail caption

                $query = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE (approved = 'YES' AND hits > 0 AND UNIX_TIMESTAMP(mtime) > $last24) $META_ALBUM_SET $keyword ORDER BY UNIX_TIMESTAMP(mtime) DESC, filename  $limit";
                $result = cpg_db_query($query);

                $rowset = cpg_db_fetch_rowset($result);
                mysql_free_result($result);

                if ($set_caption) build_caption($rowset,array('hits'));

                $rowset = CPGPluginAPI::filter('thumb_caption_topn',$rowset);

                return $rowset;
                break;

I added that to the "functions.inc.php" file and test it manually and it work, but I do not know how to generate a link automatically like the one for most viewed.

Seem like it is
Code: [Select]
<li><a href="{TOPN_TGT}" title="{TOPN_LNK}">{TOPN_LNK}</a></li>
like that in the theme.php in the theme folder. But I do not know how to generate the link like

http://www.ehmongmusic.com/thumbnails.php?album=last6&cat=0

automatically. Can someone help me?

Thank You
Title: Re: Last viewed within 6 hours only
Post by: Sami on June 18, 2007, 10:54:40 am
You should Edit your theme.php and

-Add theme_main_menu() function to themes/your theme/theme.php from themes/sample/theme.php (if you don't have it already)

- Edit that function and add this to $param array of else statement
Code: [Select]
        '{LAST6_TGT}' => "thumbnails.php?album=last6$cat_l2",
        '{LAST6_TITLE}' => $lang_main_menu['last6_title'],
        '{LAST6_LNK}' => $lang_main_menu['last6_lnk'],

- Add the link to your custom $template_sub_menu by adding this
Code: [Select]
<li><a href="{LAST6_TGT}" title="{LAST6_TITLE}">{LAST6_LNK}</a></li>

- Edit language file (i.e. english.php) and add 'last6_title' and 'last6_lnk' to $lang_main_menu array ,something like this
Code: [Select]
'last6_lnk' => 'Last view(6 hr)',
'last6_title' => 'Last view within 6 hours',

You are Done !

It would be better to change this
Code: [Select]
$rowset = CPGPluginAPI::filter('thumb_caption_topn',$rowset);
to this
Code: [Select]
$rowset = CPGPluginAPI::filter('thumb_caption_last6',$rowset);
that would help plugin API to see your mod for further plugin codding (http://forum.coppermine-gallery.net/index.php?topic=32501.0) ;)
Title: Re: Last viewed within 6 hours only
Post by: dreams83 on June 19, 2007, 10:24:17 pm
Thank You,

Got it Now.