Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
Hi,

my header is embedded on every page (<cms:embed 'header.php'/>) with the head-meta-title-...-tags inside.

1. I have some blogposts with description, image, ... for these meta tags.
2. I also have other pages without any meta-information available.

Is it possible that I have the default value of my meta tags (open graph) overwritten after embedding my header.php ?

Thanks!
Hi,

The code in an embedded snippet, for all practical purposes, can be considered as if it were physically present in the template the snippet is embedded in.

So, suppose the header snippet has the following statement -
Code: Select all
<cms:show my_meta />

Further suppose we have two templates, blog.php and contact.php, with the header embedded in both.

When the blog.php template executes, the <cms:show my_meta /> statement will behave as if it was physically present in blog.php itself (as opposed to a separate snippet). Therefore, it will try to find a variable named 'my_meta' in the context of blog.php itself - if there is an editable region named 'my_meta' in the template, it will show its value in the statement.

The same will happen with the other template, contact.php. If an editable region named 'my_meta' is present in it its value will be show. Else, the statement will output an empty value.

To make your embedded code output some default values for templates that do not have the editable region in question, you may use conditionals e.g.
Code: Select all
<cms:if my_meta>
    <cms:show my_meta />
<cms:else />
    <cms:show 'Some default text' />
</cms:if>

Please use the info about to structure your snippet.
For more involved case, you may find the following feature useful - https://docs.couchcms.com/miscellaneous ... embed.html

Hope this helps.
2 posts Page 1 of 1