Documentation

Light-weight, fast, simple and powerful!
 
Translations of this page?:

Introduction

This plugin provides an easy to use, blog-style articles setup to your Wolf CMS installation. It is included in the default Wolf CMS setup.

It has been bundled with the core since version 0.5.0.

Examples of how to set up the different kinds of archive pages follow:

For information about date formatting in the examples below, see the notes on the date() function.

The linking code given below has been updated for 0.7.7. (May 2013) and should not be used for earlier versions.

Annual Archive

In the “blog” (news, articles) branch, create a page with the following settings:

  • Title: %Y archive
  • Slug: annual-archive (must be adjusted manually)
  • Breadcrumb: %Y archive (created automatically)
  • Page Type: Archive year index
  • Status: Hidden
  • Filter: -none-

Page content:

<?php $archives = $this->archive->get(); ?>
<?php foreach ($archives as $archive): ?>
<div class="archive entry">
  <span class="date"><?php echo $archive->date(); ?></span>
  <h3><?php echo $archive->link(); ?></h3>
</div>
<?php endforeach; ?>

Link code:

To link to an annual archive, use this code as a starting point (it may need adjusting):

<?php $article = $this->find('news'); ?> // change "news" to slug of blog branch
<?php $year-archives = $article->archive->archivesByYear(); ?>
 
<ul>
<?php foreach ($year-archives as $date): ?>
  <li><a href="<?php echo $this->url(false) .'/'. $date . URL_SUFFIX; ?>"><?php echo $date ?></a></li>
<?php endforeach; ?>
</ul>

Monthly Archive

This page is created by default when Wolf is installed.

In the “blog” (news, articles) branch, create a page with the following settings:

  • Title: %B %Y archive
  • Slug: monthly-archive (must be adjusted manually)
  • Breadcrumb: %B %Y archive (created automatically)
  • Page Type: Archive month index
  • Status: Hidden
  • Filter: -none-

Page content:

<?php $archives = $this->archive->get(); ?>
<?php foreach ($archives as $archive): ?>
<div class="entry">
  <h3><?php echo $archive->link(); ?></h3>
<div class="post-date">Posted by <?php echo $archive->author(); ?> on <?php echo $archive->date(); ?></div>
</div>
<?php endforeach; ?>

Link code:

To link to a monthly archive, use this code as a starting point (it may need adjusting):

<?php $article = $this->find('news'); ?> // change "news" to slug of blog branch
<?php $month-archives = $article->archive->archivesByMonth(); ?>
 
<ul>
<?php foreach ($month-archives as $date): ?>
  <li><a href="<?php echo $this->url(false) .'/'. $date . URL_SUFFIX; ?>"><?php echo strftime('%B %Y', strtotime(strtr($date, '/', '-'))); ?></a></li>
<?php endforeach; ?>
</ul>

Daily Archive

In the “blog” (news, articles) branch, create a page with the following settings:

  • Title: %a, %e %b %Y archive
  • Slug: daily-archive (must be adjusted manually)
  • Breadcrumb: %a, %e %b %Y archive (created automatically)
  • Page Type: Archive day index
  • Status: Hidden
  • Filter: -none-

Page content:

<?php $archives = $this->archive->get(); ?>
<?php foreach ($archives as $archive): ?>
<div class="archive entry">
  <span class="date"><?php echo $archive->date(); ?></span>
  <h3><?php echo $archive->link(); ?></h3>
</div>
<?php endforeach; ?>

Link code:

To link to a daily archive, use this code as a starting point (it may need adjusting):

<?php $article = $this->find('news'); ?> // change "news" to slug of blog branch
<?php $day-archives = $article->archive->archivesByDay(); ?>
 
<ul>
<?php foreach ($day-archives as $date): ?>
  <li><a href="<?php echo $this->url(false) .'/'. $date . URL_SUFFIX; ?>"><?php echo strftime('%e %B %Y', strtotime(strtr($date, '/', '-'))); ?></a></li>
<?php endforeach; ?>
</ul>
 
plugins/archive.txt · Last modified: 2013-05-29 22:38 by David
 
Except where otherwise noted, content on this wiki is licensed under the following license:GNU Free Documentation License 1.2
Copyright 2010 wolfcms.org / design by yello studio / Wolf CMS Inside