Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: [1] 2

Author Topic: archive - months list  (Read 9041 times)

Fyner

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
archive - months list
« on: November 16, 2008, 06:33:18 PM »

Hello. I tried to do the same, but the strikes only to errors  :-[
Maybe someone tried to do as an archives on this page:
Quote
http://wp-themes.com/carrington-blog/

If yes, please help me...
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: archive - months list
« Reply #1 on: November 16, 2008, 07:33:39 PM »

Not much info to go on Fyner... your link is to a Wordpress blog and we do not provide assistance to problems associated with Wordpress.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fyner

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
Re: archive - months list
« Reply #2 on: November 16, 2008, 07:50:48 PM »

Not much info to go on Fyner... your link is to a Wordpress blog and we do not provide assistance to problems associated with Wordpress.

Yes Yes, I know... But I want do this (archive) in my snews. I want shows list months (archive), and when I click same months from list I see post from this months.

Quote
http://wp-themes.com/carrington-blog/
this site is only example, what i want to do...
Logged

jlhaslip

  • Sr. Member
  • ****
  • Karma: 16
  • Posts: 374
    • My snews with AEF Forum site
Re: archive - months list
« Reply #3 on: November 17, 2008, 04:15:45 AM »

He wants Archive as an Extra rather than a Page
Logged
Yes! I have no siggy.

Fyner

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
Re: archive - months list
« Reply #4 on: November 19, 2008, 01:16:08 AM »

anyone?
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: archive - months list
« Reply #5 on: November 19, 2008, 07:19:54 PM »

anyone?

Sure... that's pretty easy.  :)
1 - Open your sNews index.php file in your good code editor.
2 - Decide where you want to try this out - where you want your "Archive" page's content to show.
3 -  Copy the archive function's name-tag in there... with PHP tags wrapping it... as we do with other sNews functions:
        <php archive(); ?>
4 - Go back to view your "Home Page" and the Archive function will be displaying its contents where you put it.

Now... you are probably going to ask... "How do I get rid of the current Archive page link?"
1 - Open your snews.php file and use your "search" to locate (search for) - function pages()
2 - Scroll down in the function and disable the 4th and 5th strings by commenting them out as shown below.
     Or... if you have not modified your pages function in the past, just replace your with this one:

Code: [Select]
<?php

function pages() {
$categorySEF get_id('category'); $pageSEF get_id('article'); $home l('home_sef');
$class = (empty($categorySEF) || $categorySEF == $home && empty($pageSEF)) ? ' class="current"' '';
echo '<li><a'.$class.' href="'.db('website').'" title="'.l('home').'">'.l('home').'</a></li>';
// $class = ($categorySEF == 'archive') ? ' class="current"' : '';
// echo '<li><a'.$class.' href="'.db('website').'archive/" title="'.l('archive').'">'.l('archive').'</a></li>';
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 3 ORDER BY id"
$result mysql_query($query);
while ($r mysql_fetch_array($result)) {
        # 1.6.0 - new variable, used in 3rd string below
$title $r['title'];
$class = ($pageSEF == $r['seftitle'])? ' class="current"' '';
if ($r['id'] != s('display_page')) {
# 1.6.0 - new variable in 2 places
echo '<li><a'.$class.' href="'.db('website').l('home_sef').'/'.$r['seftitle'].'/" title="'.$title.'">'.$title.'</a></li>';
}
}
$class = ($categorySEF == 'contact') ? ' class="current"''';
echo '<li><a'.$class.' href="'.db('website').'contact/" title="'.l('contact').'">'.l('contact').'</a></li>';
$class = ($categorySEF == 'sitemap') ? ' class="current"''';
echo '<li><a'.$class.' href="'.db('website').'sitemap/" title="'.l('sitemap').'">'.l('sitemap').'</a></li>';
}

?>


Your next question might be... "How do I change the way the archive function displays? I don't like the way it looks now."
1 - Again... in the snews.php file... search for - function archive() which brings you to the start of the function.
    This function generates what gets displayed.
Code: [Select]
<?php

function archive() {
echo '<h2>'.l('archive').'</h2>'// #1 - DISPLAYS THE TITLE -  "Archive".
$query "SELECT * FROM ".db('prefix')."articles WHERE position = 1 AND published = 1 ORDER BY date DESC"
$result mysql_query($query);
echo '<p>';
# 1. 1.6.0 - if / else - 2 lines added, not in 1.5.31
if (!$result || !mysql_num_rows($result)) {echo l('article_not_exist');}
else {
$home l('home_sef');
$home_name l('home');
$month_names explode(', 'l('month_names'));
while ($r mysql_fetch_array($result)) {
$year substr($r['date'], 04);
$month substr($r['date'], 52) -1;
$month_name = (substr($month01) == 0) ? $month_names[substr($month11)] : $month_names[$month];
$categorySEF $r['category'] != find_cat_sef($r['category']) : $home;
$articleSEF retrieve('seftitle''articles''id'$r['id']);
$cat_name $r['category'] != retrieve('name''categories''seftitle'$categorySEF) : $home_name;
$title $r['title'];
// #2 - NEXT STRING DISPLAYS: the month/year sub-headings using: $month_name & $year
if ($last <> $year.$month) {echo '<strong>'.$month_name.', '.$year.'</strong><br />';}
// #3 - NEXT STRING DISPLAYS: all article links by month - article title followed by Category in brackets.
echo l('divider').' <a href="'.db('website').$categorySEF.'/'.$articleSEF.'/" title="'.$title.'">'.$title.'</a> ('.$cat_name.')<br />';
// #4 - NEXT STRING DISPLAYS: all article links by month - article title ONLY.
// echo l('divider').' <a href="'.db('website').$categorySEF.'/'.$articleSEF.'/" title="'.$title.'">'.$title.'</a><br />';
$last $year.$month;
}
}
echo '</p>';
}

?>


Following the orange comment lines in the function above...
#1 - displays the "Archive" title. You can change the HTML heading tags - h2 -  to something smaller or that is defined in your CSS.
#2 - displays the mont & year sub-headings.
#3 - displays the article text links with the Category name in brackets after them.
#4 - displays the article text links WITHOUT the category name in brackets.
       If you don't want the category name to show, comment out the string after #3 and un-comment the one after #4.

I hope that gives you a good start.  ;)




« Last Edit: November 19, 2008, 07:21:57 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fyner

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
Re: archive - months list
« Reply #6 on: November 20, 2008, 12:54:30 PM »

well almost :)

such a small project for better understanding what i want...



So... The right display to me only months, and when I click on the May to the left (content) will show me a list of topics that were written in may....
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: archive - months list
« Reply #7 on: November 20, 2008, 02:25:41 PM »

Then... to get expandable month/year sub-headings that show the article links... you'd need to wrap the month/year string in function archive() with an onclick="toggle() link to toggle a hidden division that will then wrap the article link string. You'd also do a little change to have function toggle (located in the jscript section at the end of snews.php) active when no one is logged in so it will toggle your month/year divisions... as it is (be default) only active when the Admin is logged in.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: archive - months list
« Reply #8 on: November 20, 2008, 06:33:33 PM »

um, not quite Doug...
What seems to be required is an archive by month link set, and when link is selected, shortened versions(or just links?) are shown in the main content area. Not a toggled listing.

This might require some extensive coding, but it would be similar to articles list displayed when a category lik is selected... the only difference being that it is month/year used to filter article extraction from db, not cat/subcat
Logged
Of all the things I have lost, it is my mind that I miss the most.

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: archive - months list
« Reply #9 on: November 20, 2008, 06:39:22 PM »

um, not quite Doug...
What seems to be required is an archive by month link set, and when link is selected, shortened versions(or just links?) are shown in the main content area. Not a toggled listing.

OK - I didn't realize that. Me sorry. That would be rather complicated to achieve... I was looking a a fairly simple approach.  :P
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: archive - months list
« Reply #10 on: November 21, 2008, 07:32:00 PM »

@ Phil and Fyner:
I've been toying with this a bit... it's 'sorta' working but not quite.

1 - Cloned a copy of function archive() and re-named it as function side_archive_titles()
     - using 1 query to the articles table to SELECT published articles grouped by month(date,
       to show month/year titles as links in the template sidebar. The query may need changing yet.
     - Modified the link for all generated month/year titles, pointing to new function - archive_links/.

2 - Removed the section that shows the article links and put it in the new function archive_links().
     - Using 2 queries - one to get the month/year titles again (same as in function side_archive_titles()
       and the other to display the article links.

3 - Added a new case-string under the existing case string for archive in function center() as shown:
Code: [Select]
<?php

case 'archive'archive(); break;
case 
'archive_links'archive_links(); break;

?>


4 - In the language variables array... added archive_links as a hard-coded category in the $l ['cat_listSEF'] string... and a language variable $l['archive_links'] = 'Archive Links'; to show in the breadcrumbs string when the page is displayed.

Result - Clicking any month/year title in the side-bar's side_archive_titles() function displays all available month/year titles as headings with their respective article links under them... in function center() as desired.

PROBLEM - They way I'm using the queries is displaying articles links for all available month/year titles instead of only the one we click in the side-bar month/year title list.

My knowledge of how to get one function to show data based on the instructions (links clicked) in the other function is limited... but I'll keep toying with this.
« Last Edit: November 21, 2008, 07:34:52 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: archive - months list
« Reply #11 on: November 24, 2008, 08:37:56 PM »

My knowledge of how to get one function to show data based on the instructions (links clicked) in the other function is limited... but I'll keep toying with this.

My apologies for not getting further on this... It appears to be beyond me at this point in time.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fyner

  • Newbie
  • *
  • Karma: 0
  • Posts: 28
Re: archive - months list
« Reply #12 on: December 07, 2008, 07:24:31 PM »

anyone knows how to do it in its entirety? or let rozpisze although exactly how to do what he wrote Keyrocks because they lost and I do not work :(
Logged

asundrus

  • Newbie
  • *
  • Karma: 1
  • Posts: 20
Re: archive - months list
« Reply #13 on: April 06, 2009, 10:31:52 PM »

Old post, but I just found it now, after I made a topic regarding this, anyways, has anyone got this working?
if so, please share the knowledge.
Logged

noonien

  • Newbie
  • *
  • Karma: 0
  • Posts: 25
Re: archive - months list
« Reply #14 on: August 07, 2009, 10:16:18 PM »

Great topic! I will try...
Logged
Pages: [1] 2