What is the best way to create a category listing page where the category name is used in both the <head>
and <body>
tags?
This is what I have at the moment:
<!DOCTYPE html>
<html lang="en">
<head>
{exp:channel:category_heading channel="news"}
{if category_name}
<title>{category_name} - News - {site_name}</title>
{if:else}
<title>Archive - News - {site_name}</title>
{/if}
{/exp:channel:category_heading}
{common-page-head}
</head>
<body class="news-listing listing">
{exp:channel:category_heading channel="news"}
<h1>{category_name}</h1>
{if category_description}
<p>{category_description}</p>
{/if}
{/exp:channel:category_heading}
{exp:channel:entries channel="news"}
<article class="news">
<h2>{title}</h2>
{body}
</article>
{/exp:channel:entries}
</body>
</html>
Whilst this works, is it bad to have the {exp:channel:category_heading}
tag twice on the same template? (i.e. excess queries).
Is there a way to place the page title into a temporary variable which can then be reused to avoid performing the same queries multiple times?