Saturday, 15 June 2013

php - Show variable in meta tag -



php - Show variable in meta tag -

i have div this:

<div id="beskrivelse" class="description html_content" itemprop="description"> {{description}} </div>

the content {{description}} made in backend.

how can create content shown in meta here:

<meta property="og:description" content=" here "/>

i syntax error if write:

<meta property="og:description" content=" {{description}} "/>

is ther simple way it? maybe set in variable of sort?

there no way me alter in backend using closed system. want have written in {{description}} shown in meta tag.

any suggestions?

using javascript can accomplish this.

<script language="javascript"> var descval = document.getelementbyid('beskrivelse').innerhtml; var paras = document.getelementsbytagname('meta'); (i = 0; < paras.length; i++) { var test = paras[i].getattribute('property'); if(test == "og:description") { paras[i].content = descval; } } </script>

fiddle demo

using devloper tool can check meta tag new content.

php jquery html tags meta

No comments:

Post a Comment