Topic: [HACK] Date Header Hack Mod
Name: Date Header
Author: StealthEye
Updated by: Nyne & Jetski
CuteNews Compatibility: 1.3.6 - * (no incompatibility reported yet)
Description: Show news by date
Look 1
2004
----
jan
feb
...2003
----
jan
feb
...
Discussion Topic:
Instructions:
for each template you want to have date headers make *TEMP_NAME*_dh
ex: Default_dh, Headlines_dh, extra_dh (the _dh must always be lowercase)
inside these templates you should use {dateheader} to display the date header text
example<?php
$template_active='<p>{dateheader}</p>
<hr>';
?>feel free to change the html inside the ' '
(you can format the php method for outputting it in the code below if needed)Open up inc/shows.inc.php.
find:echo $output; $showed++;
add above:
// Date Header if ($show_dh == true) { $config_dateheaderformat = "l, F jS Y"; if ($dateheader != date($config_dateheaderformat, $news_arr[0])) { $dateheader = date($config_dateheaderformat, $news_arr[0]); if (!isset($template) || $template == "") { include ("$cutepath/data/Default_dh.tpl"); } else { include ("$cutepath/data/".$template."_dh.tpl"); } $template_active = str_replace("{dateheader}",$dateheader, $template_active); echo $template_active; if (!isset($template) || $template == "") { include ("$cutepath/data/Default.tpl"); } else { include ("$cutepath/data/".$template.".tpl"); } }} // Date Header
*DO THIS ONLY IF YOU WANT THE DATE HEADER TO SHOW ON FULL NEWS PAGES*
find:echo $output; } } if(!$found){ echo("<div style=\"text-align: center;\">Can not find an article with id: <strong>". @(int) htmlspecialchars($id)."</strong></div>"); $CN_HALT = TRUE; break 1; } }
add above:
// Date Header if ($show_dh == true) { $config_dateheaderformat = "l, F jS Y"; if ($dateheader != date($config_dateheaderformat, $news_arr[0])) { $dateheader = date($config_dateheaderformat, $news_arr[0]); if (!isset($template) || $template == "") { include ("$cutepath/data/Default_dh.tpl"); } else { include ("$cutepath/data/".$template."_dh.tpl"); } $template_active = str_replace("{dateheader}",$dateheader, $template_active); echo $template_active; if (!isset($template) || $template == "") { include ("$cutepath/data/Default.tpl"); } else { include ("$cutepath/data/".$template.".tpl"); } }} // Date Header
in show_news.php find
unset($static, $template, $requested_cats, $category, $catid, $cat,$reverse, $in_use, $archives_arr, $number, $no_prev, $no_next, $i, $showed, $prev, $used_archives);
add inside that code just before
,$show_dh
before
);
with your CN include code also put
$show_dh=TRUE;
to activate date headers for that specific Cn include