jmcclane
jmcclane

Reputation: 189

news :: RealURL Path for MetaTag og:url for detailpage

I want to render the meta tag og:url for a detailpage of a news item. I have the following TS:

page.headerData.2999 {
    wrap = <meta property="og:url" content="{$extglobal.domain}|" />
    10 = TEXT
    10 {
        typolink {
            parameter.data = TSFE:id
            returnLast = url
        }
    }
    20 = TEXT
    20 {
        data = GP:tx_news_pi1|news
        stdWrap.wrap = &tx_news_pi1[news]=|
        required = 1
    }
}

But the url in the og:url metag tag is rendered as:

https://example.com/news/detailpage/&tx_news_pi1[news]=1671

Any ideas how to achieve the full realUrl path for og:url?

Upvotes: 0

Views: 132

Answers (2)

jmcclane
jmcclane

Reputation: 189

Thanks, I found a solution to make my TS working:

    page.headerData.1038 >
page.headerData.2999 = COA
page.headerData.2999 {
    wrap = <meta property="og:url" content="{$extglobal.domain}|" />
    10 = TEXT
    10 {
        typolink {
            parameter.data = TSFE:id
            additionalParams {
                data = GP:tx_news_pi1|news
                rawUrlEncode = 1
                wrap = &tx_news_pi1[news]=|
            }
            useCacheHash = 1
            returnLast = url
        }
    }
}

Upvotes: 0

Rudy Gnodde
Rudy Gnodde

Reputation: 4565

You have to add the additional URL parameters to the typolink part, either with additionalParams (https://docs.typo3.org/typo3cms/TyposcriptReference/latest/Functions/Typolink.html#additionalparams) or addQueryString (https://docs.typo3.org/typo3cms/TyposcriptReference/latest/Functions/Typolink.html#addquerystring). With additionalParams you can set your own parameters to add. With addQueryString you can add the parameters of the current URL to the URL.

However the news extension supports Open Graph meta tags by default. More on how to configure it can be found here: https://docs.typo3.org/typo3cms/extensions/news/stable/singlehtml/Index.html#opengraph

Upvotes: 2

Related Questions