webman
webman

Reputation: 1203

TYPO3: meta tag author, how to use both name and email

the html5 standard accepts the author tag as name and email:

<meta name="author" content="name, [email protected]">

The TYPO3 backend allows you to register them both in the Page properties as "Author Name" (field: author) and "Author Email" (field: author_email),

I know how to include the tag (I use the value recursive):

page = PAGE
page {
    meta {
        author.data = levelfield :-1, author slide
        author.override.field = author
    }
}

how do I add the email correctly with typoscript ?

Upvotes: 0

Views: 561

Answers (2)

Bernd Wilke πφ
Bernd Wilke πφ

Reputation: 10800

You probably can use a cObject which concatenates both fields within a COA.

page.meta.author.cObject = COA
page.meta.author.cObject {
    10 = TEXT
    10.data = levelfield :-1, author slide
    10.noTrimWrap = ||, |

    20 = TEXT
    20.data = levelfield :-1, author_email slide
    20.noTrimWrap = ||, |

    stdWrap.subString = 0,-2
}

As not all fields are ready to slide you need to declare these additional fields for sliding. This can be done in the install tool or an extension.
Solution for an extension: insert in your ext_localconf.php:

$rootlinefields = &$GLOBALS["TYPO3_CONF_VARS"]["FE"]["addRootLineFields"]; 
if ($rootlinefields != '') { 
    $rootlinefields .= ' , '; 
} 
$rootlinefields .= 'author,author_email';

Attention:
As author and author_email slide independently you might get a mixed content from different pages

Upvotes: 1

webman
webman

Reputation: 1203

Inspired by Bernd I have something half working:

page {
    meta {
        author.cObject = COA
        author.cObject {
            10 = TEXT
            10 {
                data = levelfield :-1, author, slide
                override.field = author
                wrap = |
            }

            20 = TEXT
            20 {
                field = author_email
                noTrimWrap = |, ||
                if {
                    isTrue.field = author_email
                    isTrue = 1
                    isTrue.if {
                        isTrue.field = author
                    }
                }
            }
        }
    }
}

like this an author will slide, but an email will only be added if there is the combination author and email on the page ...

Upvotes: 1

Related Questions