WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Blog menu snippet
  • Print
Pages: [1]   Go Down

Author Topic: Blog menu snippet  (Read 6223 times)

Offline mikejd

  • Posts: 251
Blog menu snippet
« on: October 18, 2011, 11:46:47 AM »
Has anyone used this with the current News v3.5 module?

I have tried to find info from the AMASP link to the forum but it is now very old - no posts since Feb 2010. It is a bit confusing about replacing the view.php file. Should the News v3.5 view.php file still be replaced by the one from the downloaded snippet? I have tried to compare the two files and there are a lot of differences.

Also if I replace the view.php file will this affect any other instances of the News module? I have it already on another page.

Any assistance welcome.

regards,
Mike
Logged

Offline mikejd

  • Posts: 251
Re: Blog menu snippet (SORTED)
« Reply #1 on: October 19, 2011, 01:34:48 PM »
I think I have sorted this.

I have implemented the blog menu on a test page but did not change the view.php file. At first I made no changes to the News v3.5 view.php file and it worked but there was a slight problem - clicking a month showed all posts instead of for just the month. So I amended the view.php file with changes suggested by 'skywriter' here
https://forum.WebsiteBaker.org/index.php/topic,6563.75.html (second post from the end of the thread.
and it now works correctly. It shows the correct number of posts for each category and month and, when you click on the month or category, displays the posts for that month or category.

However, there is a slight anomaly, which on consideration is probably correct, where posts that have an end date do not display, i.e. there might be 3 posts in a month but 1 is past it's end date so only 2 are displayed. At first this threw me slightly but now seems reasonable on reflection.

Hope this helps someone.

Mike
Logged

Offline sky writer

  • Posts: 926
Re: Blog menu snippet
« Reply #2 on: October 19, 2011, 06:15:36 PM »
I addressed this "anomaly" here: https://forum.WebsiteBaker.org/index.php/topic,21071.new.html#new

Still waiting for an explanation.
Logged

Offline sky writer

  • Posts: 926
Re: Blog menu snippet
« Reply #3 on: October 19, 2011, 07:02:10 PM »
I am still curious about the News Module functionality, but I have fixed my issue specific to the Blog Menu.

To properly display the number of visible posts in the Blog Menu...

In the Blog Menu module, open include.php

change:
Code: [Select]
// make database query and obtain active groups and amount of posts per group
$result = $database->query($query);
if($result->numRows() > 0){
if ($group_header != "") {
echo $group_header;
}
while($group = $result->fetchRow()){
                $id = $group['group_id'];
$query_detail = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE page_id=$page_id AND active=true AND group_id=$id;";
$detail_result = $database->query($query_detail);
$num = $detail_result->numRows();
$output .= "<li><a href=\"" .WB_URL.PAGES_DIRECTORY .$page_link .PAGE_EXTENSION ."?g=".$group['group_id']."\">" .$group['title'] ."</a> (".$num.")</li>\n";
    }
}
$output = "<ul>".$output."</ul>";
        echo $output;
}
if($display_option==0 or $display_option==1){ //show history

To:
Code: [Select]
// make database query and obtain active groups and amount of posts per group
$t = time();
$result = $database->query($query);
if($result->numRows() > 0){
if ($group_header != "") {
echo $group_header;
}
while($group = $result->fetchRow()){
                $id = $group['group_id'];
$query_detail = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE page_id=$page_id AND active=true
AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) AND group_id=$id;";
$detail_result = $database->query($query_detail);
$num = $detail_result->numRows();
$output .= "<li><a href=\"" .WB_URL.PAGES_DIRECTORY .$page_link .PAGE_EXTENSION ."?g=".$group['group_id']."\">" .$group['title'] ."</a> (".$num.")</li>\n";
    }
}
$output = "<ul>".$output."</ul>";
        echo $output;
}
if($display_option==0 or $display_option==1){ //show history

To fix the post count in the monthly Blog Menu listing:

Change:
Code: [Select]
$query = "SELECT MONTHNAME(FROM_UNIXTIME(".$date.")) as mo,MONTH(FROM_UNIXTIME(".$date.")) as m,FROM_UNIXTIME(".$date.",'%Y') as y,COUNT(*) as total FROM " .TABLE_PREFIX ."mod_news_posts WHERE page_id=$page_id AND active=true GROUP BY y,m ORDER BY y DESC,m DESC;";
To:
Code: [Select]
$query = "SELECT MONTHNAME(FROM_UNIXTIME(".$date.")) as mo,MONTH(FROM_UNIXTIME(".$date.")) as m,FROM_UNIXTIME(".$date.",'%Y') as y,COUNT(*) as total FROM " .TABLE_PREFIX ."mod_news_posts WHERE page_id=$page_id AND active=true AND (published_when = '0' OR published_when <= $t) AND (published_until = 0 OR published_until >= $t) GROUP BY y,m ORDER BY y DESC,m DESC;";
Hope this helps.
« Last Edit: October 19, 2011, 07:12:46 PM by sky writer »
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Blog menu snippet
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2