Archive and Links Pages

It would be nice to be able to have a links and/or archive page under blogsome: that just had a list of all links, or a list of all posts/months/days (whatever). The problem is that Pages cannot use template tags, and it is not much fun to update these pages by hand. A solution presented itself to me today, and it goes like this:

    {if $smarty.server.REQUEST_URI == '/links/'}
        {get_links_list}
    {elseif $smarty.server.REQUEST_URI == '/archives/'}
        {get_archives type='postbypost' limit='' format='html'}
    {/if}

This code can go into the Main Page template, just after {content}, or into the post.html template if you’ve used my previous hack to get Pages processed by the post template. You’ll also need to create Pages: Links and Archives (if you use different names, be sure to ensure the page-slug is the one that is listed in the code above). I had to put a <br /> into each Page in order to get rid of all errors. You can see the results here: Archives, Links. It’s more than likely that a similar solution exists for categories: I’ll do that too. Update: Categories, Pages. Note: Make sure you have the slash following the URL when you try to access them. It may be possible to have a double {if} clause (with slash and without), but I’m not sure yet… later works a treat:

     {if $smarty.server.REQUEST_URI == '/links/' || $smarty.server.REQUEST_URI == '/links'}
        {get_links_list}

And so on…

Smarty Hacks

While trying to solve someone elses problems, I came across the following: If you call {have_posts}, this will return a number as long as you are not on the last post to be displayed on the page. This is a standard WP function, but it is interesting to see it works under WP-MU. {the_post} will increment the post counter: basically skip a post, but will cause SQL errors. • My biggest hassle so far is that it doesn’t seem to be possible to assign stuff created by template tags to variables, other than by the very ugly {capture name=foo}{bar}{/capture} ; {$smarty.capture.foo} trick, which doesn’t work for Arrays: it just sets $smarty.capture.foo to ‘Array’, not very much use at all. {section} might be promising, but I doubt it: {foreach value=get_the_category item=each}{$each}{/foreach} just returns ‘get_the_category’.

Connections Edits

Yay! I’ve fixed the Search function so it works. I hadn’t changed the action tag to read "{$Smarty.server.PHP_SELF}", which it needed to be in order to work. What I want to do now is make the previous and next page links not have the words previous post, and next post, just the title and the double-arrows. Also, the Latest Posts does not seem to be updating…I’ll try to fix this.

Popular Post Bug

I have the following code to display my most popular posts in the sidebar: {popularposts} {if $pposts != ''}   <h2>Most Popular Posts</h2>     <ul>     {foreach from=$pposts key=key item=hits}       <li><nobr><a href="{get_permalink id=$hits.postID}" title="{$hits.title}">{$hits.title|truncate:25:"..."}</a>: {$key}</nobr></li>     {/foreach}     </ul> {/if} However, it doesn’t work: the links are all to the least recent of my recent posts the last post on the page. I’ll have to fix this. (Note: a fix is in the comments).