Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-03-08 08:55:50

joel
Member
Registered: 2004-11-26
Posts: 162

Help with modifying mkv_archive (monthly display)

Hi,

I found the most wonderful plugin for displaying monthly archives – mkv_archive. There is only one catch. When I click on the perticular month a list of articles including all comments are displayed. Would it be possible to edit the plug-in to only show the article and the comments_invite link insted?

Here is the plugin-code:
<pre>function mkn_archive( $atts )
{ global $id, $urlmode, $s, $pg;

$id = mysql_escape_string( $id ); $html = “”; if (is_array($atts)) extract($atts); $pager = isset($pager) ? $pager : ‘bottom’; $pagerclass = isset($pagerclass) ? ‘ class=”’.$pagerclass.’”’ : ‘’; $perpage = isset($perpage) ? (int)$perpage : 10; $sections = isset($sections) ? $sections : ‘’; if( $sections != ‘’ ) { if( strstr( $sections, “;” ) ) { $s_arr = explode( “;”, $sections ); foreach( $s_arr as $key => $val ) { $s_arr[“$key”] = “section = ‘$val’”; } $s_sql = “(“.implode( “ OR “, $s_arr ).”)”; } else { $s_sql = “ section=’$sections’”; } } else { $s_sql = “1”; } if( $id == “” ) { /* List of month */ $sql = “SELECT ID,Posted FROM textpattern WHERE status=‘4’ ORDER BY Posted DESC”; $rs = getRows( $sql ); if( $rs ) { $o = array(); $m = “”; $ma = “x”; $o[] = ‘<h3>Månadsvis</h3>’; $o[] = ‘<ul>’; foreach( $rs as $a ) { $m = substr( $a[“Posted”], 0, 7 ); if( $ma != $m ) { $month = $m; $url = “/”.$s.”/”.$m.”/”; $o[] = ‘<li><a href=”’.$url.’” title=“Arkiv för ‘.$month.’”>’.$month.’</a></li>’; $ma = $m; } } $o[] = ‘</ul>’; } $html = implode( “\n”, $o ); } else { /* display month/ day */ $limit = $perpage; $start = 0; $rs = getRows( “SELECT count(*) as anz FROM textpattern WHERE $s_sql AND Posted LIKE ‘$id%’ AND status=‘4’” ); $total = $rs[“0”][“anz”]; $page = (int)$pg; if( $total == 0 ) { Header( “HTTP/1.0 404 Not Found” ); die( “hier könnte man eine 404 Seite finden, aber …” ); } $numPages = ceil( $total/$limit ); $page = (!$page) ? 1 : $page; $offset = ( $page – 1 ) * $limit; for( $i = 1; $i <= $numPages; $i++ ) { $txt = “Sida $i”; if( $page==$i ) { $nav[] = ‘<strong>’.$txt.’</strong>’; } else { $url = “/”.$s.”/”.$id.”/?pg=”.$i; $nav[] = ‘<a href=”’.$url.’” title=”’.$url.’”>’.$txt.’</a>’; } } if( count( $nav ) > 1 && ( $pager==‘top’ || $pager==‘both’) ) $html .= ‘<p’.$pagerclass.’> ‘.implode( “ | “, $nav ).’ </p>’; $l = “$offset,$limit”; $sql = “ SELECT ID,Posted,section FROM textpattern WHERE $s_sql AND Posted LIKE ‘$id%’ AND status=‘4’ ORDER by Posted DESC LIMIT $l “; $rs = getRows( $sql ); if( $rs ) { foreach ($rs as $row) { extract( $row ); $html .= doArticle( array( “id” => $ID ) ); } } if( count( $nav ) > 1 && ( $pager==‘bottom’ || $pager==‘both’) ) $html .= ‘<p’.$pagerclass.’>’.implode( “ | “, $nav ).’</p>’; } return $html; } </pre>

Last edited by joel (2005-03-08 08:56:34)

Offline

#2 2005-03-09 11:55:24

joel
Member
Registered: 2004-11-26
Posts: 162

Re: Help with modifying mkv_archive (monthly display)

Got an answer directly from the autor. He has changed the plugin into what I need… :)

version 0.3

The only thing missing is the comments invite string. If someone knows how to do that, please post it here.

Thanks

Last edited by joel (2005-03-09 11:56:01)

Offline

Board footer

Powered by FluxBB