Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-05-19 03:49:14

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

[howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Some 5 1/2 year ago, I wrote:

I still it will be preferable to have monthly archive pages again someday, but until then, this will do nicely…

It has obviously taken a while but I have most of a solution now.

Two Plugins are essential to make this work: adi_gps and smd_if

1. Create a section named “archives” and use this or something very similar as the page template:

<txp:output_form form="archivetype" />

<txp:output_form form="header" />

<div id="container">

	<div id="content" role="main">

		<txp:output_form form="archivetitle" />

		<txp:output_form form="archivebody" />

	</div><!-- #content -->

</div><!-- #container -->

<txp:output_form form="sidebar" />

<txp:output_form form="footer" />

2. Create the archivetype misc form:

<txp:adi_gps />

<txp:smd_if field="txpvar:y,txpvar:m,txpvar:d" operator="isused,isused,isused">

   <txp:variable name="archivetype" value="daily" />

<txp:else />

	<txp:smd_if field="txpvar:y,txpvar:m" operator="isused,isused">

		<txp:variable name="archivetype" value="monthly" />

	<txp:else />

		<txp:smd_if field="txpvar:y" operator="isused">

			<txp:variable name="archivetype" value="yearly" />

		<txp:else />

			<txp:variable name="archivetype" value="archives" />

		</txp:smd_if>

	</txp:smd_if>

</txp:smd_if>

<txp:smd_if field="txpvar:m" operator="isused">
	<txp:php>global $variable; $month_num = variable(array("name" => "m")); $variable['monthtitle'] = date('F', mktime(0, 0, 0, $month_num));</txp:php>
</txp:smd_if>

3. Create the archivetitle misc form:

<h1 class="page-title">

<txp:if_variable name="archivetype" value="yearly">

	Yearly Archives: <span><txp:variable name="y" /></span>

</txp:if_variable>

<txp:if_variable name="archivetype" value="monthly">

	Monthly Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="y" /></span>

</txp:if_variable>

<txp:if_variable name="archivetype" value="daily">

	Daily Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /></span>

</txp:if_variable>

<txp:if_variable name="archivetype" value="archives">

	Archives

</txp:if_variable>

</h1>

4. Create the archivebody misc form:

<txp:if_variable name="archivetype" value="yearly">

	<txp:article_custom form="archives" limit="99999" month='<txp:variable name="y" />' section="article" />

</txp:if_variable>

<txp:if_variable name="archivetype" value="monthly">

	<txp:article_custom form="archives" limit="99999" month='<txp:variable name="y" />-<txp:variable name="m" />' section="article" />

</txp:if_variable>

<txp:if_variable name="archivetype" value="daily">

	<txp:article_custom form="archives" limit="99999" month='<txp:variable name="y" />-<txp:variable name="m" />-<txp:variable name="d" />' section="article" />

</txp:if_variable>

<txp:if_variable name="archivetype" value="archives">

	<txp:article_custom form="archives" limit="99999" section="article" />			

</txp:if_variable>

5. Create the archives article form:

<a href="<txp:permlink />" title="Permanent link to <txp:title />"><txp:title /></a><br />

This will give you the basic structure. To link to a specific archive, you construct links like so:

Yearly – http://cmsstyles.com/demos/twentyten/archives/?y=2011

Monthly – http://cmsstyles.com/demos/twentyten/archives/?y=2011&m=04

Daily – http://cmsstyles.com/demos/twentyten/archives/?y=2011&m=04&d=11

Complete – http://cmsstyles.com/demos/twentyten/archives/

The code I use in the sidebar to create the links to the Monthly Archives:

<li id="archives" class="widget-container">
	<h3 class="widget-title">Archives</h3>
	<ul>
		<txp:article_custom limit="99999" form="archives widget" />
	</ul>			
</li>

and in the archives widget article form:

<txp:if_different>
	<li><a href="<txp:site_url />archives/?y=<txp:posted format="%Y" />&m=<txp:posted format="%m" />"><txp:posted format="%B %Y" /></a></li>
</txp:if_different>

The header file I use is kind of complicated but this portion is the relevant for this example.

<txp:if_variable name="archivetype" value="yearly">
	<txp:variable name="y" />  | <txp:site_name />
</txp:if_variable>

<txp:if_variable name="archivetype" value="monthly">
	<txp:variable name="monthtitle" /> <txp:variable name="y" /> | <txp:site_name />
</txp:if_variable>

<txp:if_variable name="archivetype" value="daily">
	<txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /> | <txp:site_name />
</txp:if_variable>

<txp:if_variable name="archivetype" value="archives">
	Archives | <txp:site_name />
</txp:if_variable>

Further Plans: I had an idea for some error-checking but it isn’t working yet and I want to eventually do some url-rewriting. But for now, I thought it might be more productive to make it available.

Offline

#2 2011-05-25 19:28:46

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Version 2.0 – A little less readable but uses less code to do more things

1. Create a section named “archives” and use this or something very similar as the page template:

<txp:output_form form="archivetype" />

<txp:output_form form="header" />

<div id="container">

	<div id="content" role="main">

		<h1 class="page-title"><txp:variable name="archivetitle" /></h1>

		<txp:output_form form="archivebody" />

	</div><!-- #content -->

</div><!-- #container -->

<txp:output_form form="sidebar" />

<txp:output_form form="footer" />

2. Create the archivetype misc form:

<txp:adi_gps />

<txp:smd_if field="txpvar:m" operator="isused">
	<txp:php>global $variable; $month_num = variable(array("name" => "m")); $variable['monthtitle'] = date('F', mktime(0, 0, 0, $month_num));</txp:php>
</txp:smd_if>

<txp:smd_if field="txpvar:y,txpvar:m,txpvar:d" operator="isused,isused,isused">

   <txp:variable name="archivetype" value="daily" />
   <txp:variable name="archivepagetitle" value='<txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /> | <txp:site_name />' />
   <txp:variable name="archivetitle" value='Daily Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /></span>' />
   <txp:variable name="archivemonth" value='<txp:variable name="y" />-<txp:variable name="m" />-<txp:variable name="d" />' />

<txp:else />

	<txp:smd_if field="txpvar:y,txpvar:m" operator="isused,isused">

		<txp:variable name="archivetype" value="monthly" />
		<txp:variable name="archivepagetitle" value='<txp:variable name="monthtitle" /> <txp:variable name="y" /> | <txp:site_name />' />
		<txp:variable name="archivetitle" value='Monthly Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="y" /></span>' />
		<txp:variable name="archivemonth" value='<txp:variable name="y" />-<txp:variable name="m" />' />


	<txp:else />

		<txp:smd_if field="txpvar:y" operator="isused">

			<txp:variable name="archivetype" value="yearly" />
			<txp:variable name="archivepagetitle" value='<txp:variable name="y" />  | <txp:site_name />' />
			<txp:variable name="archivetitle" value='Yearly Archives: <span><txp:variable name="y" /></span>' />
			<txp:variable name="archivemonth" value='<txp:variable name="y" />' />

		<txp:else />

			<txp:variable name="archivetype" value="archives" />
			<txp:variable name="archivepagetitle" value='Archives | <txp:site_name />' />
			<txp:variable name="archivetitle" value="Archives" />
			<txp:variable name="archivemonth" value="archives" />

		</txp:smd_if>

	</txp:smd_if>

</txp:smd_if>

3. Create the archivebody misc form:

 <txp:if_variable name="archivemonth" value="archives">

	<txp:article_custom form="archivecheck" limit="1" section="article" />

<txp:else />

	<txp:article_custom form="archivecheck" limit="1" month='<txp:variable name="archivemonth" />' section="article" />

</txp:if_variable>

<txp:if_variable name="archivecheck" value="true">

	<txp:if_variable name="archivemonth" value="archives">

		<txp:article_custom form="archives" limit="99999" section="article" />

	<txp:else />

		<txp:article_custom form="archives" limit="99999" month='<txp:variable name="archivemonth" />' section="article" />

	</txp:if_variable>

<txp:else />

	<p>No articles were created during this time period.</p>

</txp:if_variable>

4. Create the archivecheck article form:

<txp:variable name="archivecheck" value="true" />

5. Create the archives article form:

<a href="<txp:permlink />" title="Permanent link to <txp:title />"><txp:title /></a><br />

and the pagetitle code is much simpler:

<txp:if_section name="archives" >
	<txp:variable name="archivepagetitle" />
</txp:if_section>

You now get a message is there are no articles to display. The archivetitle form was replaced by a variable. I left the archivetype variable in even though I didnt’ acually use it anywhere just in case someone had a use for it – it is completely optional.

Offline

#3 2012-01-26 21:47:45

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Author’s Note: This version was lost when Textdrive went away and I can’t locate a backup of mkp_archives. One reason I am storing everything on Github from now on.

Version 3.0 – this one makes creative use of error pages as well as moving the php code to a plugin

1. Create a section named “archives” and use this or something very similar as the page template:

<txp:output_form form="header-archives" />

<txp:output_form form="header" />

	<div id="primary">
		<div id="content" role="main">

<txp:output_form form="task-archives" />

		</div><!-- #content -->
	</div><!-- #primary -->

<txp:output_form form="sidebar" />

<txp:output_form form="footer" />

3. the header-archives misc form:

<txp:mkp_archive />

<txp:smd_if field="txpvar:y,txpvar:m,txpvar:d" operator="isused,isused,isused">

   <txp:variable name="archivetype" value="daily" />
   <txp:variable name="archivepagetitle" value='<txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /> | <txp:site_name />' />
   <txp:variable name="archivetitle" value='Daily Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /></span>' />
   <txp:variable name="archivemonth" value='<txp:variable name="y" />-<txp:variable name="m" />-<txp:variable name="d" />' />

<txp:else />

	<txp:smd_if field="txpvar:y,txpvar:m" operator="isused,isused">

		<txp:variable name="archivetype" value="monthly" />
		<txp:variable name="archivepagetitle" value='<txp:variable name="monthtitle" /> <txp:variable name="y" /> | <txp:site_name />' />
		<txp:variable name="archivetitle" value='Monthly Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="y" /></span>' />
		<txp:variable name="archivemonth" value='<txp:variable name="y" />-<txp:variable name="m" />' />


	<txp:else />

		<txp:smd_if field="txpvar:y" operator="isused">

			<txp:variable name="archivetype" value="yearly" />
			<txp:variable name="archivepagetitle" value='<txp:variable name="y" />  | <txp:site_name />' />
			<txp:variable name="archivetitle" value='Yearly Archives: <span><txp:variable name="y" /></span>' />
			<txp:variable name="archivemonth" value='<txp:variable name="y" />' />

		<txp:else />

			<txp:variable name="archivetype" value="archives" />
			<txp:variable name="archivepagetitle" value='Archives | <txp:site_name />' />
			<txp:variable name="archivetitle" value="Archives" />
			<txp:variable name="archivemonth" value="archives" />

		</txp:smd_if>

	</txp:smd_if>

</txp:smd_if>

3. Create the task-archives misc form:

<h1 class="page-title"><txp:variable name="archivetitle" /></h1>

<txp:variable name="archivehasarticles" value="false" />

<txp:if_variable name="archivemonth" value="archives">

	<txp:article_custom limit="1" section="article" >
		<txp:variable name="archivehasarticles" value="true" />
	</txp:article_custom>

<txp:else />

	<txp:article_custom limit="1" month='<txp:variable name="archivemonth" />' section="article" >
		<txp:variable name="archivehasarticles" value="true" />
	</txp:article_custom>

</txp:if_variable>

<txp:if_variable name="archivehasarticles" value="true">

	<txp:if_variable name="archivemonth" value="archives">

		<txp:article_custom form="archives" limit="99999" section="article" />

	<txp:else />

		<txp:article_custom form="archives" limit="99999" month='<txp:variable name="archivemonth" />' section="article" />

	</txp:if_variable>

<txp:else />

	<p>No articles were created during this time period.</p>

</txp:if_variable>

4. Create the archives article form:

<a href="<txp:permlink />" title="Permanent link to <txp:title />"><txp:title /></a><br />

5. Change the error_default page to:

<txp:output_form form="header" />

<div id="primary">
	<div id="content" role="main">

		<h1 class="page-title"><txp:error_status /></h1>

		<p class="error-msg"><txp:error_message /></p>

	</div><!-- #content -->
</div><!-- #primary -->

<txp:output_form form="sidebar" />

<txp:output_form form="footer" />

6. One key to making this work is this extremely custom error_404 page:

<txp:output_form form="header-archives" />

<txp:output_form form="header" />

	<div id="primary">
		<div id="content" role="main">

<txp:if_variable name="archivemonth" value="archives">

	<h1 class="page-title"><txp:error_status /></h1>

	<p class="error-msg"><txp:error_message /></p>

<txp:else />

	<txp:output_form form="task-archives" />

</txp:if_variable>

		</div><!-- #content -->
	</div><!-- #primary -->

<txp:output_form form="sidebar" />

<txp:output_form form="footer" />

and the pagetitle code looks like:

<txp:if_section name="default">
	<title><txp:page_title /></title>
<txp:else />
	<txp:smd_if field="txpvar:archivepagetitle" operator="isused">
		<title><txp:variable name="archivepagetitle" /></title>
	<txp:else />
		<title><txp:page_title /></title>
	</txp:smd_if>
</txp:if_section>

You will also need mkp_archive as I am sure you noticed in the header-archives form. You won’t need adi_gps anymore because this will performs the operations I was doing with that along with some reverse engineered Textpattern code.

To see this version in action, try these: Yearly, Monthly, Daily

Last edited by michaelkpate (2014-10-19 02:51:12)

Offline

#4 2014-10-19 16:27:12

candyman
Member
From: Italy
Registered: 2006-08-08
Posts: 684

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

I’ve missed this tutorial.
Anyway the links to see it in action are actually broken and the download link of mpk_archive too :(

Last edited by candyman (2014-10-19 16:28:04)

Offline

#5 2014-10-19 17:11:21

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Hello,

I wanted to add v3 but the links are all broken so don’t know if it works. Instead I did v2, this produces “Archives/ No articles were created during this time period.” at the bottom but I’m getting errors for header, sidebar and footer along the following lines:

Tag error: <txp:output_form form=“header” /> -> Textpattern Notice: Form not found: header while parsing form None on page archives

Being very new, my hunch would be that these were names/includes on the old version?

Thank you

Offline

#6 2014-10-19 17:57:17

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

K, think I got it. Replaced old archives with this, does it look about right?

<txp:output_form form="archivetype" />

<!doctype html>
<html lang="<txp:lang />">

<head>
  <meta charset="utf-8">

<!-- page title and metas, no meta keywords as they are now obsolete -->
  <title><txp:page_title /></title>
  <meta name="description" content="">
  <meta name="generator" content="Textpattern CMS">
  <txp:if_search>
    <meta name="robots" content="none">
  <txp:else />
  <txp:if_category>
    <meta name="robots" content="noindex, follow, noodp, noydir">
  <txp:else />
  <txp:if_author>
    <meta name="robots" content="noindex, follow, noodp, noydir">
  <txp:else />
    <meta name="robots" content="index, follow, noodp, noydir">
  </txp:if_author>
  </txp:if_category>
  </txp:if_search>

<!-- mobile viewport optimised, more info: http://h5bp.com/viewport -->
  <meta name="viewport" content="width=device-width, initial-scale=1">

<!-- content feeds -->
  <txp:feed_link flavor="atom" format="link" label="Atom" />
  <txp:feed_link flavor="rss" format="link" label="RSS" />
  <txp:rsd />

<!-- specify canonical, more info: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html -->
  <txp:if_section name="">
    <link rel="canonical" href="<txp:site_url />">
  <txp:else />
    <txp:if_individual_article>
      <link rel="canonical" href="<txp:permlink />">
    <txp:else />
      <link rel="canonical" href="<txp:section url='1' />">
    </txp:if_individual_article>
  </txp:if_section>

<!-- css -->
  <!-- Google font API (remove this if you intend to use the theme in a project without internet access) -->
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:n4,i4,n7,i7|Cousine">

  <txp:css format="link" media="" />
  <!-- or you can use (faster) external CSS files eg. <link rel="stylesheet" href="<txp:site_url />css/default.css"> -->

<!-- HTML5/Media Queries support for IE < 9 (you can remove this section and the corresponding 'js' directory files if you don't intend to support IE < 9) -->
  <!--[if lt IE 9]>
    <script src="<txp:site_url />js/html5shiv.js"></script>
    <script src="<txp:site_url />js/css3-mediaqueries.js"></script>
  <![endif]-->

</head>

<body id="<txp:if_section name=""><txp:if_search>search<txp:else />front</txp:if_search><txp:else /><txp:section /></txp:if_section>-page">

<!-- header -->
  <header role="banner">
    <hgroup>
      <h1><txp:link_to_home><txp:site_name /></txp:link_to_home></h1>
      <h3><txp:site_slogan /></h3>
    </hgroup>
  </header>

<!-- navigation -->
  <nav role="navigation">
    <h1><txp:text item="navigation" /></h1>
    <txp:section_list default_title='<txp:text item="home" />' include_default="1" wraptag="ul" break="">
      <li<txp:if_section name='<txp:section />'><txp:if_search><txp:else /><txp:if_category><txp:else /><txp:if_author><txp:else /> class="active"</txp:if_author></txp:if_category></txp:if_search></txp:if_section>>
        <txp:section title="1" link="1" />
      </li>
    </txp:section_list>
  </nav>

  <div class="wrapper">
    <div class="container">

<!-- left (main) column -->
      <div role="main">

<div id="content" role="main"><h1 class="page-title"><txp:variable name="archivetitle" /></h1><txp:output_form form="archivebody" /></div><!-- #content -->

			</div>


<!-- right (complementary) column -->
      <div role="complementary">
        <txp:search_input /> <!-- links by default to form: 'search_input.misc.txp' unless you specify a different form -->

        <!-- Feed links, default flavor is rss, so we don't need to specify a flavor on the first feed_link -->
        <p><txp:feed_link label="RSS" class="feed-rss" /> / <txp:feed_link flavor="atom" label="Atom" class="feed-atom" /></p>

        <h4><txp:text item="external_links" /></h4>
        <txp:linklist wraptag="ul" break="li" limit="10" /> <!-- links by default to form: 'plainlinks.link.txp' unless you specify a different form -->
      </div> <!-- /complementary -->

    </div> <!-- /.container -->
  </div> <!-- /.wrapper -->

<!-- footer -->
  <footer role="contentinfo">
    <p><small><txp:text item="published_with" /> <a href="http://textpattern.com" rel="external" title="<txp:text item='go_txp_com' />">Textpattern CMS</a>.</small></p>
  </footer>

<!-- JavaScript at the bottom for fast page loading, more info: http://developer.yahoo.com/performance/rules.html#js_bottom -->

  <!-- add your own JavaScript here -->

</body>
</html>

{Edited to add Textile’s bc. for better readability. – Uli}

Last edited by uli (2014-10-19 22:15:45)

Offline

#7 2014-10-20 03:33:20

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

ingleslenobel wrote #284957:

K, think I got it. Replaced old archives with this, does it look about right?

<txp:output_form form="archivetype" />...

{Edited to add Textile’s bc. for better readability. – Uli}

I think so. I haven’t played around with this in a while but I will take another look at it and maybe write a full tutorial using the current default template (which didn’t exist back when I created this).

Offline

#8 2014-10-20 20:27:33

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Yes I appreciate that. Thank you Michael, and for your response.

Offline

#9 2014-10-23 02:11:36

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Version 4.0 – New Plugin and the examples are designed specifically to work with the the current default template

First off, you can get the new plugin mkp_url_parameters from the Github repository (currently version 1.1). And you will still need smd_if.

Quick explanation of how this works on the new (hopefully permanent) Demo Site:

So what we are actually doing is altering the default and error_default templates to show up as article listings rather than their typical results.

header-archives:

<txp:mkp_url_parameters />

<txp:smd_if field="txpvar:y,txpvar:m,txpvar:d" operator="isused,isused,isused">

   <txp:variable name="archivetype" value="daily" />
   <txp:variable name="archivepagetitle" value='<txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /> | <txp:site_name />' />
   <txp:variable name="archivetitle" value='Daily Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="d" />, <txp:variable name="y" /></span>' />
   <txp:variable name="archivemonth" value='<txp:variable name="y" />-<txp:variable name="m" />-<txp:variable name="d" />' />

<txp:else />

	<txp:smd_if field="txpvar:y,txpvar:m" operator="isused,isused">

		<txp:variable name="archivetype" value="monthly" />
		<txp:variable name="archivepagetitle" value='<txp:variable name="monthtitle" /> <txp:variable name="y" /> | <txp:site_name />' />
		<txp:variable name="archivetitle" value='Monthly Archives: <span><txp:variable name="monthtitle" /> <txp:variable name="y" /></span>' />
		<txp:variable name="archivemonth" value='<txp:variable name="y" />-<txp:variable name="m" />' />


	<txp:else />

		<txp:smd_if field="txpvar:y" operator="isused">

			<txp:variable name="archivetype" value="yearly" />
			<txp:variable name="archivepagetitle" value='<txp:variable name="y" />  | <txp:site_name />' />
			<txp:variable name="archivetitle" value='Yearly Archives: <span><txp:variable name="y" /></span>' />
			<txp:variable name="archivemonth" value='<txp:variable name="y" />' />

		</txp:smd_if>

	</txp:smd_if>

</txp:smd_if>

default page:

<!DOCTYPE html>
<html lang="<txp:lang />">

<txp:output_form form="header-archives" />

<head>
  <meta charset="utf-8">

<txp:if_variable name="archivepagetitle" >
  <title><txp:variable name="archivepagetitle" /></title>
<txp:else />
  <title><txp:page_title /></title>
</txp:if_variable>

  <meta name="description" content="">
  <meta name="generator" content="Textpattern CMS">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <txp:if_search>
    <meta name="robots" content="none">
  <txp:else />
    <txp:if_category>
      <meta name="robots" content="noindex, follow, noodp, noydir">
    <txp:else />
      <txp:if_author>
        <meta name="robots" content="noindex, follow, noodp, noydir">
      <txp:else />
        <meta name="robots" content="index, follow, noodp, noydir">
      </txp:if_author>
    </txp:if_category>
  </txp:if_search>

  <meta name="year" content="<txp:variable name="y" />">
  <meta name="month" content="<txp:variable name="m" />">
  <meta name="day" content="<txp:variable name="d" />">
  <meta name="monthtitle" content="<txp:variable name="monthtitle" />">

  <!-- content feeds -->
  <txp:feed_link flavor="atom" format="link" label="Atom" />
  <txp:feed_link flavor="rss" format="link" label="RSS" />
  <txp:rsd />

  <!-- specify canonical, more info: http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html -->
  <txp:if_section name="">
    <link rel="canonical" href="<txp:site_url />">
  <txp:else />
    <txp:if_individual_article>
      <link rel="canonical" href="<txp:permlink />">
    <txp:else />
      <link rel="canonical" href="<txp:section url='1' />">
    </txp:if_individual_article>
  </txp:if_section>

  <!-- CSS -->
  <!-- Google font API (remove this if you intend to use the theme in a project without internet access) -->
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:n4,i4,n7,i7|Cousine">

  <txp:css format="link" media="" />
  <!-- ...or you can use (faster) external CSS files eg. <link rel="stylesheet" href="<txp:site_url />css/default.css"> -->

  <!-- HTML5/Media Queries support for IE 8 (you can remove this section and the corresponding 'js' directory files if you don't intend to support IE < 9) -->
  <!--[if lt IE 9]>
    <script src="<txp:site_url />js/html5shiv.js"></script>
    <script src="<txp:site_url />js/css3-mediaqueries.js"></script>
  <![endif]-->

</head>

<body id="<txp:if_section name=""><txp:if_search>search<txp:else />front</txp:if_search><txp:else /><txp:section /></txp:if_section>-page">

  <!-- header -->
  <header role="banner">
    <hgroup>
      <h1><txp:link_to_home><txp:site_name /></txp:link_to_home></h1>
      <h3><txp:site_slogan /></h3>
    </hgroup>
  </header>

  <!-- navigation -->
  <nav role="navigation">
    <h1><txp:text item="navigation" /></h1>
    <txp:section_list default_title='<txp:text item="home" />' include_default="1" wraptag="ul" break="">
      <li<txp:if_section name='<txp:section />'><txp:if_search><txp:else /><txp:if_category><txp:else /><txp:if_author><txp:else /> class="active"</txp:if_author></txp:if_category></txp:if_search></txp:if_section>>
        <txp:section title="1" link="1" />
      </li>
    </txp:section_list>
  </nav>

  <div class="wrapper">
    <div class="container">

      <!-- left (main) column -->
      <div role="main">

<txp:if_variable name="archivepagetitle" >

        <h1><txp:variable name="archivetitle" /></h1>

        <txp:article listform="article_listing" limit="99999" />

<txp:else />

      <!-- is this result result page? also omits the pagination links below (uses pagination format within search_results.article.txp instead) -->
      <txp:if_search>

        <h1><txp:text item="search_results" /></h1>
        <txp:output_form form="search_results"/>

      <txp:else />

        <!-- else is this an article category list? -->
        <txp:if_category>

          <h1><txp:text item="category" /> <txp:category title="1" /></h1>
          <txp:article form="article_listing" limit="5" />

        <txp:else />

          <!-- else is this an article author list? -->
          <txp:if_author>

          <h1><txp:text item="author" /> <txp:author /></h1>
          <txp:article form="article_listing" limit="5" />

          <txp:else />

            <!-- else display articles normally -->
            <txp:article limit="5" /> <!-- links by default to form: 'default.article.txp' unless you specify a different form -->

          </txp:if_author>
        </txp:if_category>

        <!-- add pagination links to foot of article/article listings/category listings if there are more articles available,
          this method is more flexibile than using simple txp:link_to_prev/txp:link_to_next or txp:older/txp:newer tags -->
        <p id="paginator">

        <txp:variable name="prev" value='<txp:older />' />
        <txp:variable name="next" value='<txp:newer />' />

        <txp:if_variable name="prev" value="">
          <span id="paginator-l" class="button disabled">&#8592; <txp:text item="older" /></span>
        <txp:else />
          <a id="paginator-l" href="<txp:older />" title="<txp:text item='older' />" class="button">&#8592; <txp:text item="older" /></a>
        </txp:if_variable>
        <txp:if_variable name="next" value="">
          <span id="paginator-r" class="button disabled"><txp:text item="newer" /> &#8594;</span>
        <txp:else />
            <a id="paginator-r" href="<txp:newer />" title="<txp:text item='newer' />" class="button"><txp:text item="newer" /> &#8594;</a>
        </txp:if_variable>

        </p>

      </txp:if_search>

</txp:if_variable>



      </div> <!-- /main -->

      <!-- right (complementary) column -->
      <div role="complementary">
        <txp:search_input /> <!-- links by default to form: 'search_input.misc.txp' unless you specify a different form -->

        <!-- Feed links, default flavor is rss, so we don't need to specify a flavor on the first feed_link -->
        <p><txp:feed_link label="RSS" class="feed-rss" /> / <txp:feed_link flavor="atom" label="Atom" class="feed-atom" /></p>

        <h4><txp:text item="external_links" /></h4>
        <txp:linklist wraptag="ul" break="li" limit="10" /> <!-- links by default to form: 'plainlinks.link.txp' unless you specify a different form -->
      </div> <!-- /complementary -->

    </div> <!-- /.container -->
  </div> <!-- /.wrapper -->

  <!-- footer -->
  <footer role="contentinfo">
    <p><small><txp:text item="published_with" /> <a href="http://textpattern.com" rel="external" title="<txp:text item='go_txp_com' />">Textpattern CMS</a>.</small></p>
  </footer>

  <!-- add your own JavaScript here -->

</body>
</html>

error_default page:

<!DOCTYPE html>
<html lang="<txp:lang />">

<txp:if_status status="404">
<txp:output_form form="header-archives" />
</txp:if_status>

<head>
  <meta charset="utf-8">

<txp:if_variable name="archivepagetitle" >
  <title><txp:variable name="archivepagetitle" /></title>
<txp:else />
  <title><txp:page_title /></title>
  <meta name="description" content="<txp:error_message />">
</txp:if_variable>

  <meta name="generator" content="Textpattern CMS">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="robots" content="none">
  <meta name="year" content="<txp:variable name="y" />">
  <meta name="month" content="<txp:variable name="m" />">
  <meta name="day" content="<txp:variable name="d" />">
  <meta name="monthtitle" content="<txp:variable name="monthtitle" />">

  <!-- content feeds -->
  <txp:feed_link flavor="atom" format="link" label="Atom" />
  <txp:feed_link flavor="rss" format="link" label="RSS" />
  <txp:rsd />

  <!-- CSS -->
  <!-- Google font API (remove this if you intend to use the theme in a project without internet access) -->
  <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Serif:n4,i4,n7,i7|Cousine">

  <txp:css format="link" media="" />
  <!-- ...or you can use (faster) external CSS files eg. <link rel="stylesheet" href="<txp:site_url />css/default.css"> -->

  <!-- HTML5/Media Queries support for IE 8 (you can remove this section and the corresponding 'js' directory files if you don't intend to support IE < 9) -->
  <!--[if lt IE 9]>
    <script src="<txp:site_url />js/html5shiv.js"></script>
    <script src="<txp:site_url />js/css3-mediaqueries.js"></script>
  <![endif]-->

</head>

<txp:if_variable name="archivepagetitle" >
<body id="front-page">
<txp:else />
<body id="error-page">
</txp:if_variable>

  <!-- header -->
  <header role="banner">
    <hgroup>
      <h1><txp:link_to_home><txp:site_name /></txp:link_to_home></h1>
      <h3><txp:site_slogan /></h3>
    </hgroup>
  </header>

  <!-- navigation -->
  <nav role="navigation">
    <h1><txp:text item="navigation" /></h1>
    <txp:section_list default_title='<txp:text item="home" />' include_default="1" wraptag="ul" break="li">
      <txp:section title="1" link="1" />
    </txp:section_list>
  </nav>

  <div class="wrapper">
    <div class="container">

      <!-- left (main) column -->
      <div role="main">

<txp:if_variable name="archivepagetitle" >

        <h1><txp:variable name="archivetitle" /></h1>

        <txp:article listform="article_listing" limit="99999" />

<txp:else />

         <h1 class="error-status"><txp:error_status /></h1>
        <p class="error-msg"><txp:error_message /></p>

</txp:if_variable>

      </div> <!-- /main -->

      <!-- right (complementary) column -->
      <div role="complementary">
        <txp:search_input /> <!-- links by default to form: 'search_input.misc.txp' unless you specify a different form -->

        <!-- Feed links, default flavor is rss, so we don't need to specify a flavor on the first feed_link -->
        <p><txp:feed_link label="RSS" class="feed-rss" /> / <txp:feed_link flavor="atom" label="Atom" class="feed-atom" /></p>

        <h4><txp:text item="external_links" /></h4>
        <txp:linklist wraptag="ul" break="li" limit="10" /> <!-- links by default to form: 'plainlinks.link.txp' unless you specify a different form -->
      </div> <!-- /complementary -->

    </div> <!-- /.container -->
  </div> <!-- /.wrapper -->

  <!-- footer -->
  <footer role="contentinfo">
    <p><small><txp:text item="published_with" /> <a href="http://textpattern.com" rel="external" title="<txp:text item='go_txp_com' />">Textpattern CMS</a>.</small></p>
  </footer>

  <!-- add your own JavaScript here -->

</body>
</html>

Feedback, as you might imagine, is welcome.

Offline

#10 2014-10-29 15:24:42

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Hello Michael,

I’m almost certainly doing something silly but this isn’t playing nicely for me – see this example page

It may very well be because I didn’t know what header-archives is meant to be – I guessed a misc form but I suspect that’s completely wrong?

Thank you very much,

-Johan

Offline

#11 2014-10-29 15:52:47

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

ingleslenobel wrote #285218:

Hello Michael,

I’m almost certainly doing something silly but this isn’t playing nicely for me – see this example page

It may very well be because I didn’t know what header-archives is meant to be – I guessed a misc form but I suspect that’s completely wrong?

I think you are pointing out how bad I am at writing directions. :)

header-archives is indeed a miscellaneous form – I noted that on version 3 but not on version 4. Technically, you could just add the code to the page forms but I prefer to separate out the code when I can – especially when it will be used more than once.

I noticed that in your example the url of the first blog post is: http://extreme-macro.co.uk/extremist/extremist+blog+test

I am assuming this means you haven’t set the Permanent Link Mode to /year/month/day/title in your Preferences. Because I would expect to see something more like: http://www.datebasedarchives.cmsstyles.com/2014/10/29/blog-test which shouldn’t be strictly necessary (I just tested and this worked anyway) but seems more logical.

The subdirectory though may be a problem. Let me check on that.

Offline

#12 2014-10-29 17:07:28

ingleslenobel
Member
Registered: 2014-10-16
Posts: 88

Re: [howto] Date-Based Archives - Yearly, Monthly, Daily, and Complete

Cool, I guessed right:)

In truth I’m completely new to textpattern and hadn’t realised that I needed to change the permanent link mode to use this. Doing so is a bit of a problem for me from the SEO point of view sadly.

What I’m really after is the ability for users to browse to articles several ways. By category, and by date but all those having a permanent url which uses the title. Ie a topnav item that says archives, that goes to some page which has a treelike list descending by date, and the items link to /pagetitle/ pages, with the latter being the permanent link.

Does that make sense – does your work do something like this or am I way off :)

Thank you

Offline

Board footer

Powered by FluxBB