Hi,
I'm having an issue auto-generating my description tags.
In each page template I have:
{capture assign=metadescription}{content block="metadescription" label="META Description" oneline="true"}{/capture}
just before the </__html> tag.
In the metadata tag I have:
<meta name="description" content="{if isset($metadescription)}{$metadescription}{else}{$main_content|strip_tags|truncate:'200'|strip}{/if}"/>
The idea being, if the metadescription block is filled in, it displays that, if not, it grabs the first 200 words form the main_content block.
This seems to work on some of my sites, but not all?
Any suggestions?
Next, i'll try and get the og:image tag to auto generate..
Thanks for any help.
Cheers,
Another metadescription tag question - sorry
Re: Another metadescription tag question - sorry
Why it doesn't work is hard to understand from this post.
First
It's not clear what would be the difference between the installs. You should debug this by printing out the contents of the $metadescription variable.
Tips:
forum has[/code]
it is said that using capture is less efficient than using the assign parameter on the tag if available:
First
What 'does not work' mean exactly?This seems to work on some of my sites, but not all?
It's not clear what would be the difference between the installs. You should debug this by printing out the contents of the $metadescription variable.
Tips:
forum has
Code: Select all
[code] code tags
Code: Select all
{capture assign=metadescription}{content block="metadescription" label="META Description" oneline="true"}{/capture}
Code: Select all
{content block="metadescription" label="META Description" oneline="true" assign="metadescription"}
Re: Another metadescription tag question - sorry
wouldn't
always be true if it's assigned above?
try
Code: Select all
{if isset($metadescription)}
try
Code: Select all
{if ! empty($metadescription)}
Re: Another metadescription tag question - sorry
Doh. Many many thanks rotezecke.
Yep, that will do it, and thanks for the advice velden, I'll move them all away from the {capture} method.
I really do appreciate the help.
Cheers,
Paul
Yep, that will do it, and thanks for the advice velden, I'll move them all away from the {capture} method.
I really do appreciate the help.
Cheers,
Paul
Re: Another metadescription tag question - sorry
Out of interest, I've seen some recommendations for the metadescription content block to be before and after the close body (<__body>) tag. Which is the recommended way?
or
Thanks again.
Code: Select all
{content block="metadescription" label="META Description" oneline="true" assign="metadescription"}
<__body>
</__html>
Code: Select all
<__body>
{content block="metadescription" label="META Description" oneline="true" assign="metadescription"}
</__html>
Re: Another metadescription tag question - sorry
neither makes sense.
while not necessary, i think it is good practice to assign content early in your template, before any html output.
while not necessary, i think it is good practice to assign content early in your template, before any html output.
Re: Another metadescription tag question - sorry
Thanks again, really do appreciate the help, even if I'm showing my ignorance at every turn!
Cheers,
Cheers,