[pmwiki-users] Looking for advise on how to create a blog archive

Hans design5 at softflow.co.uk
Fri Jul 4 19:32:18 CDT 2008

Sunday, June 29, 2008, 7:59:22 PM, Jan Erik Moström wrote:

> 2008-05 May
>     2008-05-01 11:56    kasjh dsaoij dasjd dsajdsjkds jdks
>     2008-05-01 15:23    jlkj fdsiojrew jdsalj dasljd alskdjas dsalj
>     ...
>     2008-05-06 23.58    Some clever title
>     2008-05-07 12:13    daslj dsaöljd sdakj dsalkdj asdlkj

> I've been trying to figure out how I should create these archive
> listings. I could probably come up with some way of creating static
> pages, that is I create the main index page manually and then create
> an archive page for each month using pagelists for creating the actual
> listing. But it would be *much* nicer if everything was created
> dynamically ... unfortunately I don't have an idea if this is possible
> and if it's practical (and efficient) to do it this way.

For a dynamic list you can use pagelist markup with a custom format template.
Try something like this:

(:pagelist group=Blog list=normal order=-name fmt=#blogindex :)

!!!!#blogindex template
(:if !equal {(substr '{<$Name}' 0 4)} {(substr '{=$Name}' 0 4)} :)'''{(substr '{=$Name}' 0 4)}'''(:if:)
->(:if !equal {(substr '{<$Name}' 4 2)} {(substr '{=$Name}' 4 2)} :)'''{(ftime %B '{=$Name}')}'''(:if:)
-->[[{=$Name}]] &nbsp;&ndash;&nbsp; {{=$FullName}$Title}

If you are happy with your blogindex template put it in
Site.LocalTemplates so it is not visible on the page.

The output from my example looks something like this (I did not
use hours and minute page parts):

      20080705  –  title abcdefg
      20080704  –  xyz
      20080515  –  title blabla
      20080505  –  aaaaa
      20080415  –  bbbbb
      20080410  –  ccccc
      20080315  –  qwqwqw

      20070515  –  wewewew
      20070510  –  rtrtrrr
      20070410  –  tytttyty

Some explanations:

order=-name means reverse name order, which brings up newest pages to
the top, ie. reverse date order, since the page names are date

fmt=#blogindex will use your custom template as output format.
The first conditional checks the year part of the name, by using substr
markup expression it compares the previous page year part with the
actual page year part, and outputs the year part (ie. the year) if
they are not the same.
The second conditional checks the month part of the name similarly,
but this time uses ftime markup expression to output a proper month
The page line item is outputted as name link followed by the title.
Modify as needed, but I hope you get the idea.

Is a dynamic list efficient? You may run into time problems if your
archive gets too big, too many pages. I think the page titles are all
cached, so it should not be too bad. Pagelists can get slow if all
pages need to be opened in order to compile the list.


More information about the pmwiki-users mailing list