In a previous post I discussed my feeling that the next/prev links which appear at the base of the overview pages, I call them the page footer, were flawed, and I
suggested a fix for this. I believe this creates a more visually appealing link than the original serendipity default.
The page footer is comprised of three elements, the previous link, the footer info, and the next link. This article suggests a usability enhancement so that where either the next or previous link is missing, for example on the startpage, that instead of the link being left out, the link text will remain in position but greyed out and not clickable.
I have two reasons for suggesting this improvement. First, users become accustomed to seeing these links and the greyed out link text is a friendlier method of alerting them that they have reached the end or beginning of the overview pages. Secondly, I like the symmetry of seeing the page footer maintain its position and size across all overview pages.
This is the smarty and html code used in serendipity by default.
{if $footer_prev_page}
<a href="{$footer_prev_page}">« {$CONST.PREVIOUS_PAGE}</a>  
{/if}
{if $footer_info}
({$footer_info})
{/if}
{if $footer_next_page}
<a href="{$footer_next_page}">» {$CONST.NEXT_PAGE}</a>
{/if}
As you can see from this, if a previous page exists it will print the previous page link, and similarly if the next page exists it will print the next page link. However if the pages do not exist the {if} statement simply exits without printing anything.
Adding the greyed out link text
Now how could we change the smarty code so that instead of skipping the link text, it actually inserts the greyed out version? Relatively easily as the following code demonstrates;
{if $footer_info}
{if $footer_prev_page}
<a href="{$footer_prev_page}">« {$CONST.PREVIOUS_PAGE}</a>  
{else}
<span class="grey">« {$CONST.PREVIOUS_PAGE}</span>  
{/if}
{/if}
{if $footer_info}
({$footer_info})
{/if}
{if $footer_info}
{if $footer_next_page}
  <a href="{$footer_next_page}">{$CONST.NEXT_PAGE} »</a>
{else}
  <span class="grey">{$CONST.NEXT_PAGE} »</span>
{/if}
{/if}
You'll notice immediately that I've inserted an additional {if} statement for both the previous and next link code. You'll also notice that I've included an {else} statement within the second if statement.
Let me take you back a step and explain a little more about the page footer. The footer info text is only generated for overview pages, it does not appear in detail pages. This is important to know if you're going to play around with the serendipity template files. Knowing this, it makes sense that if you want to alter the default method code you also need to make sure your user is on an overview page. Forget this step and the greyed out previous link text could appear on a detail page. Ah, so you could put some extra text into the detail page as well, yup, you can, but lets stick to dealing with the overview page footer links for now.
The first {if} statement in my page footer asks the question, are we on an overview page, and if the answer is yes, serendipity will then start to process the second if statement. If the answer is no, then we exit the {if} statement and continue on to the footer info text that appears between the links.
The second {if} statement is very similar to the code in the default method, except that it includes an {else} statement. What happens now is that if a previous page exists we insert the link exactly as normal, but if this doesn't exist, then we leave out the <a href...> text, and place a <span> around the link text, and at the same time added the class
.grey so that my link text isn't the same color as the footer info text.
My last step is to add the new style to the theme stylesheet, like this;
.grey {
color:#999; }