Page 1 of 1

Show meta description only if set

Posted: Sun Apr 13, 2008 1:59 pm
by oliver341
Hi, I've got this in my template:

Code: Select all

<meta name="description" content="{description}" />
However, I'd like to hide this line altogether if I haven't entered anything in the page's Description box. Is this possible with an if statement?

Re: Show meta description only if set

Posted: Sun Apr 13, 2008 2:39 pm
by alby
oliver341 wrote:

Code: Select all

<meta name="description" content="{description}" />
However, I'd like to hide this line altogether if I haven't entered anything in the page's Description box. Is this possible with an if statement?
Try this:

Code: Select all

{capture name="metadescription"}{description}{/capture}
{if $smarty.capture.metadescription ne ''}<meta name="description" content="{description}" />{/if}
Alby

Re: Show meta description only if set

Posted: Sun Apr 13, 2008 11:26 pm
by oliver341
Many thanks Alby, that works just fine.