Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: ( Solved ) Expandable Archive (months) and Sitemap (pages)?  (Read 3327 times)

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca

A question... to anyone...
Has anyone managed to make the content links by month/year expandable in the Archive function... and the same for pages sections in the Sitemap function?

I have been fiddling with this in the Archive function off and on for a couple of days without luck... using onclick="toggle (jscript)... I only get one link in each month rather than all of the links for the month. If anyone has a solution to share... I would find it most useful.  :)
« Last Edit: July 14, 2008, 08:35:44 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

centered

  • Guest
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #1 on: July 11, 2008, 10:32:16 pm »

Doug,

There is a solution in the 1.4 and 1.5 forums that should get you in the right direciton
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #2 on: July 12, 2008, 05:07:02 am »

Doug,

There is a solution in the 1.4 and 1.5 forums that should get you in the right direciton

Thanks EQ... I'll have a look-see there... only looked through the 1.6 sections.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #3 on: July 12, 2008, 10:06:21 am »

I have this Mod by Bakercad on my drive:
Quote
[MOD]Site Map (collapsible/expandable)

WARNING!! - This will not work for users with javascript disabled

DEMO

1. Backup snews.php file

2. function title() - ADD the blue

if ($_SESSION[db('website').'Logged_In'] == token()) {js();}
    toggle_div();
}

3. function sitemap() - replace the original function with the code below or comment out the original

function sitemap() {
    echo '<h2>'.l('sitemap').'</h2>';
    echo '<p><strong><a onclick="toggle(\'sub1\')" style="cursor: pointer;" title="'.l('home').'">'.l('pages').'</a></strong></p>';
    echo '<div id="sub1" style="display: none;">';
    $link = l('divider').' <a href="'.db('website');
    echo '<p>'.$link.'" title="'.l('home').'">'.l('home').'</a>';
    echo '<a href="'.db('website').'archives/">'.l('archives').'</a><br />';
    $query = "SELECT * FROM ".db('prefix')."articles WHERE position = 3 AND published = '1' ORDER BY id";
    $result = mysql_query($query);
    while ($r = mysql_fetch_array($result)) {
        if ($r['id'] != s('display_page')) { echo l('divider').' <a href="'.db('website').s('home_sef').'/'.$r['seftitle'].'/">'.$r['title'].'</a><br />'; }
    }
    echo $link.'contact/">'.l('contact').'</a><br />';
    echo $link.'sitemap/">'.l('sitemap').'</a><br />';   
    echo $link.'rss/">'.l('rss_feed').'</a></p>';
    echo '</div>';
    echo '<p><strong>'.l('articles').'</strong></p>';
    $art_query = "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = '1'";
    $query = $art_query." AND category = 0 ORDER BY date DESC";
    $result = mysql_query($query);
    echo '<p><strong><a onclick="toggle(\'sub2\')" style="cursor: pointer;" title="'.l('home').'">'.l('home').'</a></strong></p>';
    echo '<div id="sub2" style="display: none;">';
    while ($r = mysql_fetch_array($result)) {
        echo $link.find_cat_sef($r['category']).'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a><br />';
    }
    echo '</div>';
    $cat_query = "SELECT * FROM ".db('prefix')."categories WHERE published = 'YES'";
    $cat_result = mysql_query($cat_query);
    $num = mysql_num_rows($cat_result);
    $i = 3;
    while ($c = mysql_fetch_array($cat_result)) {
        echo '<p><strong><a onclick="toggle(\'sub'.$i.'\')" style="cursor: pointer;" title="'.$c['description'].'">'.$c['name'].'</a></strong></p>';
        echo '<div id="sub'.$i.'" style="display: none;">';
        $catid = $c['id'];
        $query = $art_query." AND category = $catid ORDER BY id DESC";
        $result = mysql_query($query);
        while ($r = mysql_fetch_array($result)) {
            $date = date(s('date_format'), strtotime($r['date']));
            echo $link.$c['seftitle'].'/'.$r['seftitle'].'/" title="'.$r['title'].'">'.$r['title'].'</a><br />';
        }
        echo '</div>';
        $i++;
}}

4. function js() - REMOVE the following

// toggle dynamic divs
    function toggle(div) {
        if (document.getElementById(div).style.display=='') {
            document.getElementById(div).style.display = 'none';
            return
        } document.getElementById(div).style.display = '';
    }

5. ADD the blue- BEFORE the very last line of snews.php

<?php }
function toggle_div() { ?>
<script type="text/javascript">
    // toggle dynamic divs
    function toggle(div) {
        if (document.getElementById(div).style.display=='') {
            document.getElementById(div).style.display = 'none';
            return
        } document.getElementById(div).style.display = '';
    }
</script>
<?php } ?>
Dose someone knows if there's a way to have pagination too on sitemap and archive pages? ???

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #4 on: July 13, 2008, 01:11:25 am »

Thanks Inspector... that's Bakercad's Archive by Month mod... I located it yesterday but I probably won't get a chance to try it out until Monday.

I do not really know how the default pagination function is integrated to work with articles on category pages. Pagination (by default) is applied to "break and create" pages based on the number of articles-per-page setting in the SETTINGS >> CONTENT panel. Perhaps it would be necessary to clone the pagination function and make one unique to the Archive page... then figure out what to use to trigger the "break & create" part to create the pages. I don't know what would work there.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Sven

  • ULTIMATE member
  • ******
  • Karma: 88
  • Posts: 2029
  • Chasing MY bugs!
    • hiseo.fr - rédacteur Web
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #5 on: July 13, 2008, 06:42:46 pm »

I do not really know how the default pagination function is integrated to work with articles on category pages. Pagination (by default) is applied to "break and create" pages based on the number of articles-per-page setting in the SETTINGS >> CONTENT panel. Perhaps it would be necessary to clone the pagination function and make one unique to the Archive page... then figure out what to use to trigger the "break & create" part to create the pages. I don't know what would work there.
I'm gonna check that next week.
Have a nice sunday Doug.

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #6 on: July 13, 2008, 11:14:31 pm »

I think is a good place for a discussion.

My points:
- for archive page is ok and we want to have pagination because content on blogs is increasing fast (and we can make pagination).
- for sitemap page is a little weird. Why? Well, for sitemap pages, in what sitemap you must include them ;D ?

Good. But sitemap is increasing also, and became very hard to load (again, we speak about blogs - cms and mysql killers) . And here is my main question:
  Is not enough to have only links to static pages, hard coded pages, and categories? And speaking about google sitemap modification which all we have included in our sites. When we have "zillions" of articles, is not too hard for google (and not productive at all) to download such a big sitemap?

I think this is very serious. We already have old articles indexed by google... why to send them again and again? Google bot is still travel on all our site links. Not send them does not mean you don't have them anymore or google must remove them. For removal you must do a specific action if I remember well. Is not enough to send only every  last 100 articles by example?

This way we can remove another  bottle neck performance.
« Last Edit: July 13, 2008, 11:16:42 pm by funlw65 »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #7 on: July 14, 2008, 05:48:25 pm »

...............................................................................
Is not enough to send only every  last 100 articles by example?
...............................................................................

This mean, a new article is sent to google in a "google sitemap"  100 times until he "disappear" from sitemap page. But still on your site and google will verify his existence time to time...

What do you think? What google "think" about this? Any specialist around here?

Google will index a page with original and relevant content with and without sitemap... But better with sitemap, we know that..
« Last Edit: July 14, 2008, 05:55:50 pm by funlw65 »
Logged

Joost

  • Guest
Re: Expandable Archive (months) and Sitemap (pages)?
« Reply #8 on: July 14, 2008, 06:49:46 pm »

I think is a good place for a discussion.

Not realy. Anyway, I'll step into this discussion.
SEO angle:

Once a page is indexed, known to Google, Google will check its existence and modifications now and then.
An html sitemap used to be a great helper for Google, making it easier to navigate and index a site. Now Google sitemaps has taken over that task. That's to say: Google would like to see every site to have a file named sitemap.xml. That way, Google can find a new page or check a modified one, without having to browse the whole site, saving both Google and the site resources.

Visitors angle:

If a visitor accesses a page named sitemap, or archive he/she expects to find an overview of all content on the site. Not just the latest 100.

Technical angle:

I am not so much worried about the page size that's  been transmitted.  The biggest worry is the amount of queries needed to generate al list (2 per link average).
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: ( Solved ) Expandable Archive (months) and Sitemap (pages)?
« Reply #9 on: July 14, 2008, 08:31:52 pm »

GETTING BACK TO THE ORIGINAL TOPIC...  (searchability aside) ;)

The approach used in Bakercad's Expandable Archive Page months worked nicely (with a few modifications) in my current project. The Archive Page is much shorter with the month/year titles collapsed... and works the same way on the modified Sitemap Page... leaving the viewer to click-through to whatever they are looking for by month or category.

« Last Edit: July 14, 2008, 08:36:05 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

robsayles

  • Newbie
  • *
  • Karma: 0
  • Posts: 4
Re: ( Solved ) Expandable Archive (months) and Sitemap (pages)?
« Reply #10 on: July 17, 2008, 01:44:17 pm »

Hey Keyrocks/all,

I'm running 1.6 with WYSIWYG mod, and like the idea of the expanding archive (looks good on mycallandar.com Keyrocks).
What mods did you make to Bakercads code, and how (as an admin) do I actually tick/stripe an article to move it into archive?
Does the mod then work out the month and assign the expander automatically?

ATB
Rob
^_^
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: ( Solved ) Expandable Archive (months) and Sitemap (pages)?
« Reply #11 on: July 17, 2008, 02:56:08 pm »

Hey Keyrocks/all,
I'm running 1.6 with WYSIWYG mod, and like the idea of the expanding archive (looks good on mycallandar.com Keyrocks).

1 - What mods did you make to Bakercads code?
2 - How (as an admin) do I actually tick/stripe an article to move it into archive?
3 - Does the mod then work out the month and assign the expander automatically?

ATB Rob

1 - I made several changes to Bakercad's code to accomplish other desired outcomes, and they depend on the application.
    For a default sNews 1.6 snews.php file, the only changes are css styling, which I've added to this complete function (below).
    You could comment out your currently active function and insert this one to test it out:

NOTE: You will also need to make sure the other mods are applied to work with this function.

Code: [Select]
<?php

/*------------------------------------------------------------------------------
  Archive Function for sNews 1.6
  By:      Bakercad
  Ref:     http://snewscms.com/forum/index.php?topic=4361.msg29577#msg29577
  Modified by: keyrocks - added css styled division & title (July 17.08)
  ------------------------------------------------------------------------------*/

// ARCHIVE
function archive() {
   echo 
'<h2>'.l('archive').'</h2>';
   
$query "SELECT date FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 GROUP BY month(date) ORDER BY date DESC";
   
$result mysql_query($query);
   
$num mysql_num_rows($result);
   
$home s('home_sef');
   
$home_name l('home');
   
$month_names explode(', 'l('month_names'));
   
$i 1;
   while (
$r mysql_fetch_array($result)) {
      
$year_month date('Y-m',strtotime($r['date']));
      
$year substr($r['date'], 04);
      
$month substr($r['date'], 52) -1;
      
$month_name = (substr($month01) == 0) ? $month_names[substr($month11)] : $month_names[$month];
      echo 
'<div class="expanding_div"><p class="expanding_title"><a title="'.$month_name.', '.$year.'" onclick="toggle(\'sub'.$i.'\')" style="cursor: pointer;"><strong>'.$month_name.', '.$year.'</strong></a></p></div>';
      echo 
'<div id="sub'.$i.'" style="display: none;">';
         
$query1 "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 AND date LIKE '$year_month%' ORDER BY date DESC";
         
$result1 mysql_query($query1);
         while (
$r1 mysql_fetch_array($result1)) {
            
$categorySEF $r1['category'] != find_cat_sef($r1['category']) : $home;
            
$articleSEF retrieve('seftitle''articles''id'$r1['id']);
            
$cat_name $r1['category'] != retrieve('name''categories''seftitle'$categorySEF) : $home_name;
            echo 
l('divider').' <a href="'.db('website').$categorySEF.'/'.$articleSEF.'/" title="'.$r1['title'].'">'.$r1['title'].'</a> ('.$cat_name.')
'
;
            
$last $year.$month;
         }
      echo 
'</div>';
   
$i++;
   }
}

?>


And then add this CSS to the CSS stylesheet containing your Admin CSS, so it will apply to the month/year titles and provide the horizontal separator line between the sections.

2 - You do not have to do anything to an article (when creating new or editing) to have it show up in the Archive page.
     As long as it is "Published", it will automatically be added to the list.

3 - This modified function applies the expandability to all months in which there are articles published.
     Month/year titles are auto-generated for every month that has at least one article published within it.
« Last Edit: July 17, 2008, 02:58:59 pm by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU