wiki:snippets/Template/Alt Text for Images-Metatags

Alt Text for Images and Metatags

In Corinis there are no "real" metatags, which does not mean you cannot create them.

The <corinis-attribute> tag allows you to create any combination of alt/meta/... descriptions and tags in a template.

The trick is to combine corinis-attribute with corinis-field. Where the corinis-field is only displayed in edit mode.

image alt

<corinis-field type="image" name="imagename">
   <corinis-exist name="imagealt"><corinis-attribute name="alt"><corinis-field type="get" name="imagealt"/></corinis-exist>
</corinis-field>
<corinis-comment>
   Alt tag for image: <corinis-field type="edit" name="imagealt"/>
</corinis-comment>

Not the corinis-exist tag: If you do not specify an alt-tag (either by writing it directly in corinis-field or using corinis-attribute) the name of the chosen image will be used as alt tag. Using the corinis-exist technique, you always have the "default" name (=imagename) and only have the specified one when someone actually enters it.

Metatags

Using the same technique you can easily create metatags. I normally use tags more than once (like a title or abstract, they are desplayed in-page and also as metatags and in the page title), this way people can have REALLY descriptive metatags without having to worry about them.

<head>
<title>My personal homepage - <corinis-field type="get" name="title"/></title>
<corinis-exist name="abstract">
  <meta name="description">
    <corinis-attribute name="content"><corinis-field type="get" name="abstract"/></corinis-attribute>
  </meta>
</corinis-exist>
</head>

<body>
<h1><corinis-field type="edit" name="title"/></h1>
<div class="abstract"><corinis-field type="richedit" name="abstract"/></div>
</body>