Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: [Q] I'd like modification of 'archive' function  (Read 11789 times)

Manuel Pancorbo

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 72
[Q] I'd like modification of 'archive' function
« on: December 12, 2006, 12:30:04 AM »

When your site grows up, the article render fills too quickly the page.

I propose to show only the month-year as 'onclik'-links, much like the settings-page and other: when clicking the month-year reference, the article's titles under it got displayed.

How should I do it?

TIA
Logged

Manuel Pancorbo

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 72
[Q] I'd like modification of 'archive' function
« Reply #1 on: December 12, 2006, 01:32:22 AM »

OK, I have it!

I'll post it soon. See the result:

http://bitakoro.blogdns.org/
Logged

mike1

  • Full Member
  • ***
  • Karma: 6
  • Posts: 199
[Q] I'd like modification of 'archive' function
« Reply #2 on: December 12, 2006, 05:30:43 AM »

NICE :D

cant wait
Logged

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[Q] I'd like modification of 'archive' function
« Reply #3 on: December 12, 2006, 06:15:18 AM »

Moved from Mods/addons.
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[Q] I'd like modification of 'archive' function
« Reply #4 on: December 12, 2006, 07:35:29 AM »

@mpancorbo

Did you by some chance, set up and test while logged in to your site??
Or do you have the toggle routine located in a different file?

Archive wouldn't toggle for me... and looking at the source, there was no visible javascript toggle() function.

Since that script is automatically present when you are logged in, you tend not to think about it.

If the above is the case, use the toggle script in the mod I posted recently, and set it to display only when logged in by using this  call at the start of the archives routine.
   
Quote
if (!isset($_SESSION[db('website').'Logged_In'])){jsuser();}
Alternatively, if you look at the title function, the last line is
   
Quote
if (isset($_SESSION[db('website').'Logged_In'])) {js();}
and can be re-written as
   
Quote
if (isset($_SESSION[db('website').'Logged_In'])) {js();}else{jsuser();}
providing that you use the jsuser() function in the mod linked above. A neater solution anyway...
Logged
Of all the things I have lost, it is my mind that I miss the most.

Manuel Pancorbo

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 72
[Q] I'd like modification of 'archive' function
« Reply #5 on: December 12, 2006, 11:15:16 AM »

Quote from: philmoz
@mpancorbo

Did you by some chance, set up and test while logged in to your site??
Or do you have the toggle routine located in a different file?

Archive wouldn't toggle for me... and looking at the source, there was no visible javascript toggle() function.
Well... 'toggle' function *is* placed between 'tag' and 'dependancy' functions in the javascript section. I'm using sNews 1.5RC3 (but it is present in stable version).

This is the code (old code is commented out):
Code: [Select]
// ARCHIVE
function archive() {
echo '<h2>'.l('archive').'</h2>';
$query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC";
$result = mysql_query($query);
//echo '<p>';;
$home = s('home_sef');
$home_name = l('home');
$month_names = explode(', ', l('month_names'));
$firsttime = true;
while ($r = mysql_fetch_array($result)) {
$year = substr($r['date'], 0, 4);
$month = substr($r['date'], 5, 2) -1;
$month_name = (substr($month, 0, 1) == 0) ? $month_names[substr($month, 1, 1)] : $month_names[$month];
$categorySEF = $r['category'] != 0 ? find_cat_sef($r['category']) : $home;
$articleSEF = retrieve('seftitle', 'articles', 'id', $r['id']);
$cat_name = $r['category'] != 0 ? retrieve('name', 'categories', 'seftitle', $categorySEF) : $home_name;
/*
if ($last <> $year.$month) {echo '<strong>'.$month_name.', '.$year.'</strong>
';}
echo l('divider').' <a href="'.db('website').$categorySEF.'/'.$articleSEF.'/" title="'.$r['title'].'">'.$r['title'].'</a> ('.$cat_name.')
';
$last = $year.$month;
*/
if ($last <> $year.$month) {
if($firsttime == true){ echo '<ul>'; $firsttime = false;}
else { echo '</ul>'."\n";}
echo '<li><a title="'.$month_name.', '.$year.'" onclick="toggle(\''.$year.$month.'\')" style="cursor: pointer;">'.$month_name.', '.$year.'</li>';
echo '<ul id="'.$year.$month.'" style="display: none;">';
}
echo '<li><a href="'.db('website').$categorySEF.'/'.$articleSEF.'/" title="'.$r['title'].'">'.$r['title'].'</a> ('.$cat_name.')</li>';
$last = $year.$month;
}
echo '</ul></ul>'."\n";
}
I will improve it with the use of 'strftime' function, that provides time and date in own locale format (instead of using the month table).
« Last Edit: February 22, 2009, 05:14:40 AM by Joost »
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[Q] I'd like modification of 'archive' function
« Reply #6 on: December 12, 2006, 11:24:49 AM »

Quote from: mpancorbo
Well... 'toggle' function *is* placed between 'tag' and 'dependancy' functions in the javascript section. I'm using sNews 1.5RC3 (but it is present in stable version).
My point being, the  
// JAVASCRIPT FUNCTIONS
function js()

is only called into the page IF and ONLY IF you are logged in to admin by the code found in
// TITLE
function title()
Quote
echo '';
   echo '';
   if (isset($_SESSION[db('website').'Logged_In'])) {js();}
}
That is the only place the js() function is call throughoout snews.php.--- I've checked :D


I can't log into your admin, so your archive toggle won't work for me   :/
Logged
Of all the things I have lost, it is my mind that I miss the most.

Manuel Pancorbo

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 72
[Q] I'd like modification of 'archive' function
« Reply #7 on: December 12, 2006, 11:28:53 AM »

Quote from: philmoz
Quote from: mpancorbo
Well... 'toggle' function *is* placed between 'tag' and 'dependancy' functions in the javascript section. I'm using sNews 1.5RC3 (but it is present in stable version).
My point being, the  
// JAVASCRIPT FUNCTIONS
function js()

is only called into the page IF and ONLY IF you are logged in to admin.

I can't log into your admin, so your archive toggle won't work for me   :/
Hell! I *see* what you mean (I didn't understand before; I thought your problem was *while on login* )

It's a pity,  yes :-(
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[Q] I'd like modification of 'archive' function
« Reply #8 on: December 12, 2006, 11:36:02 AM »

Quote from: mpancorbo
It's a pity,  yes :-(
It's easily fixable....

If the toggle worked for you when you were logged into your admin area, if you instal the jsuser() function as described above, then regular users (like me) will have toggle acces to your archive lists.

The jsuser() is the same toggle script, just made useable outside the snews js().
Logged
Of all the things I have lost, it is my mind that I miss the most.

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
[Q] I'd like modification of 'archive' function
« Reply #9 on: December 12, 2006, 11:51:52 AM »

Have installed your altered Archives...
With jsuser() installed, Archives now toggle well....

A neat solution.
Logged
Of all the things I have lost, it is my mind that I miss the most.

Mika

  • Hero Member
  • *****
  • Karma: 9
  • Posts: 1377
    • http://www.ni5ni6.com/
[Q] I'd like modification of 'archive' function
« Reply #10 on: December 12, 2006, 11:54:04 AM »

when you're done modding and satisified with the looks of it, please make a post in Mods/addons section ;)
Logged
http://www.ni5ni6.com/ - Tutorials, Mods and How-To's about sNews CMS
sNews 1.6 Developers Edition - commented sNews 1.6 version

Manuel Pancorbo

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 72
[Q] I'd like modification of 'archive' function
« Reply #11 on: December 12, 2006, 12:21:31 PM »

OK. It works. Thanks for the advice, philmoz. My first reaction was putting 'toggle' out of the 'js' in a separate javascript file, to be always included. But your solution is smarter because it is "sNews compliant" ;-)


Quote from: Mika
when you're done modding and satisified with the looks of it, please make a post in Mods/addons section ;)
Phil, can you do it? The mod needs your patch and you can explain it better than me.

Thanks!
Logged

Manuel Pancorbo

  • Jr. Member
  • **
  • Karma: 0
  • Posts: 72
[Q] I'd like modification of 'archive' function
« Reply #12 on: December 12, 2006, 04:32:35 PM »

Quote from: mpancorbo
Phil, can you do it? The mod needs your patch and you can explain it better than me.
I'll do it. I've also made a 'toggled' sitemap function, so I'll present both.
Logged

michael kennedy

  • Full Member
  • ***
  • Karma: 3
  • Posts: 207
    • SpektreDesign
[Q] I'd like modification of 'archive' function
« Reply #13 on: February 22, 2007, 08:54:05 PM »

Very nice, thanks for posting that code mpancorbo. It was just what I was looking for.  I had to slightly modify mine since I'm using scriptaculous effects.  Check it out:

http://peo.plesearch.com/psn2/sitemap/

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
[Q] I'd like modification of 'archive' function
« Reply #14 on: February 22, 2007, 09:00:57 PM »

Nice site Mike! ;)
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU
Pages: [1] 2