FORUMS CLOSED DUE TO SPAM. YOU STILL CAN ADD POST!

Archive By Month Doesnt Work

Feed 6 posts, 2 voices

Avatar
108 posts

It lists the links which is cool but when you click on them it just says this page cannot be found.

<?php $article = $this->find('/latest-news/'); ?>
<?php $archives = $article->archive->archivesByMonth(); ?>
<h2>Archives By Month</h2>
<?php foreach ($archives as $date): ?>
<a href="<?php echo BASE_URL .'latest-news/'. $date . URL_SUFFIX; ?>"><?php echo strftime('%B %Y', strtotime(strtr($date, '/', '-'))); ?></a>
<?php endforeach; ?>

Incidentally the “recent news items” snippet works perfectly which uses:

<h2>Recent Entries</h2>
<?php $page_article = $this->find('/latest-news/'); ?>
<?php foreach ($page_article->children(array('limit' => 3, 'order' => 'page.created_on DESC')) as $article): ?>
<?php echo $article->link(); ?> 
<?php endforeach; ?>

Could anyone help?

 
Avatar
48 posts

1. on what level are “latest news”?
2. you are missing <ul> and <li>

 
Avatar
108 posts

Hi Jackie,

Thanks for coming back to me…
domain.co.uk/latest-news/

Also…
I am not using the UL LI so thats not an issue.

Cheers

 
Avatar
48 posts

Try this:

<?php $article = $this->find('/latest-news'); ?>
<?php $archives = $article->archive->archivesByMonth(); ?>
<h2>Archives By Month</h2>
<?php foreach ($archives as $date): ?>
<a href="<?php echo BASE_URL . $this->url .'/'. $date . URL_SUFFIX; ?>"><?php echo strftime('%B %Y', strtotime(strtr($date, '/', '-'))); ?></a>
<?php endforeach; ?>

I still don’t understand why are you not using <ul> and <li>.

 
Avatar
108 posts

Unfortunately that didnt work…

It just keeps coming up with page cannot be found!

 
Avatar
48 posts

Yes I see, but this does not produces that error. This works fine, as it only links you to your archive page for certain month.

Your problem is in the body area, not sidebar.
Do you have under the “Latest news” a child called “%B%Y archive” (set to hidden)?
If you didn’t change anything, you should have it, and if you had, than paste this code into body of the “%B%Y archive”:

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

This should do it.

 
Avatar
108 posts

Cheers mate, you helped alot…

If i tell you what it was you’ll laugh…that archive page i didnt notice had gone up a level so it wasnt under the latest-news.

I never noticed it before. Sorry to waste your time but you definately helped me narrow it down!

Cheers Jackie