Hi,
I want to get news title to meta tag. I made it with smarty and jquery and it works fine with browser. But I want to share news in Facebook and it does not execute javascript when parsing page so it must be done in server side.
So I wrote UDT that reads smarty variable but the problem is that the variable set with news is not available before content has passed so i cannot get it to the head.
Does anyone has solutions to this?
News title to meta tag og:title in head
Re: News title to meta tag og:title in head
This has been discussed here quite a few times...
assign a variable to what you want to pass in News template, call the var in the <head>, the pages are processed with the <head> last...
assign a variable to what you want to pass in News template, call the var in the <head>, the pages are processed with the <head> last...
Re: News title to meta tag og:title in head
First line of your page template:
This will assign the content of {title} to the variable $title
In the <head> section of your page template:
Note: that the dollar sign is used in {$title}
In your News detail template:
This will overwrite the earlier set $title variable with content of $entry->title (which I assume is your news item title).
<head> section is processed AFTER </__body> section of template by CMSMS. So this should work.
Something like that.
Code: Select all
{title assign='title'}
In the <head> section of your page template:
Code: Select all
<title>{$title}</title>
<meta your facebook og tag content="{$title}">
In your News detail template:
Code: Select all
{assign var='title' value=$entry->title}
<head> section is processed AFTER </__body> section of template by CMSMS. So this should work.
Something like that.
Re: News title to meta tag og:title in head
Thanks for your answers!velden wrote: <head> section is processed AFTER </__body> section of template by CMSMS. So this should work.
I found now the solution, i have whole site header in global content block because i have multiple templates that has same header and footer. Those are prosessed earlier and does not work from there, <head> must be in template. So I must put head to the templates.
Re: News title to meta tag og:title in head
Since I learned about template inheritance I don't use GCB for that purpose anymore:
http://www.i-do-this.com/blog/Smarty-te ... -Simple/57
http://www.i-do-this.com/blog/Smarty-te ... -Simple/57