Skip to content

Commit

Permalink
added the weblog month archive page
Browse files Browse the repository at this point in the history
  • Loading branch information
iamcal committed Nov 2, 2010
1 parent d220ef9 commit 3b1c24d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
1 change: 1 addition & 0 deletions .htaccess
Expand Up @@ -25,6 +25,7 @@ RewriteRule ^stations/(\d+)/add/$ /station_add.php?id=$1 [L,QSA]
RewriteRule ^edit/$ /edit.php [L]

RewriteRule ^weblogs/$ /weblogs.php [L]
RewriteRule ^weblogs/(\d\d\d\d)-(\d\d)/$ /weblogs_month.php?y=$1&m=$2 [L,QSA]
RewriteRule ^weblogs/(\d+)/$ /weblog.php?id=$1 [L,QSA]
RewriteRule ^weblogs/(\d+)/edit/([^/]+)/$ /weblog_edit.php?id=$1&sig=$2 [L,QSA]
RewriteRule ^weblogs/(\d+)/delete/([^/]+)/$ /weblog_delete.php?id=$1&sig=$2 [L,QSA]
Expand Down
49 changes: 49 additions & 0 deletions templates/page_weblogs_month.txt
@@ -0,0 +1,49 @@
{capture assign='title'}Weblogs added in {$display_month}{/capture}
{include file='inc_head.txt'}

{if $blogs|@count}

<div class="section">
{if $blogs|@count>1}
<h1>All {$blogs|@count} Weblogs added in {$display_month}</h1>
{else}
<h1>Weblogs added in {$display_month}</h1>
{/if}

<p><a href="/weblogs/">&laquo; Back to the weblog month archive</a>.</p>
</div>

<div class="col">
<div class="section">
{include file='inc_weblogs.txt' weblogs=$blogs|@slice:2:1}
</div>
</div>

<div class="col">
<div class="section">
{include file='inc_weblogs.txt' weblogs=$blogs|@slice:2:2}
</div>
</div>

<div style="clear: both"></div>

<div class="section">
<p><a href="/weblogs/">&laquo; Back to the weblog month archive</a>.</p>
</div>

{else}
<div class="section">
<h1>Weblogs added in {$display_month}</h1>

{if $is_future}
<p>There are no weblogs from the future. Yet.</p>
{else}
<p>There were no weblogs added in {$display_month}.</p>
{/if}

<p><a href="/weblogs/">&laquo; Back to the weblog month archive</a>.</p>
</div>
{/if}


{include file='inc_foot.txt'}
35 changes: 35 additions & 0 deletions weblogs_month.php
@@ -0,0 +1,35 @@
<?
include("include/init.php");

loadlib('blogs');


#
# get blogs
#

$y = intval($_GET['y']);
$m = intval($_GET['m']);

if ($m < 1 || $m > 12) error_404();

if ($y < 2000 || $y > 2038) error_404();

$ts = mktime(0,0,0,$m,1,$y);

$smarty->assign('display_month', date('F Y', $ts));
$smarty->assign('is_future', $ts > time());

$d = sprintf('%04d-%02d-01', $y, $m);

$ret = db_fetch("SELECT * FROM tube_weblogs WHERE month_create='$d' ORDER BY blog_name ASC");

$smarty->assign_by_ref('blogs', $ret['rows']);


#
# output
#

$smarty->display('page_weblogs_month.txt');
?>

0 comments on commit 3b1c24d

Please sign in to comment.