Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Describe htmlTag_stdWrap for hreflang usage #1332

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

garvinhicking
Copy link
Contributor

See https://review.typo3.org/c/Packages/TYPO3.CMS/+/85049

This documentation should help to allow people to use other custom <html lang="..."> attribution, which was not clearly enough phrased. We would need a proper documentation entry to properly close the underlying issue.

Releases: main, 12.4

See https://review.typo3.org/c/Packages/TYPO3.CMS/+/85049

This documentation should help to allow people to use
other custom `<html lang="...">` attribution, which
was not clearly enough phrased. We would need a proper
documentation entry to properly close the underlying
issue.
brotkrueml
brotkrueml previously approved these changes Sep 13, 2024
Comment on lines +567 to +568
config.htmlTag_stdWrap.override = <html lang="{siteLanguage:hreflang}">
config.htmlTag_stdWrap.override.insertData = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of "override" which is a condition (if content is there, or not) I would prefer to use some more basic stdWrap property:

Suggested change
config.htmlTag_stdWrap.override = <html lang="{siteLanguage:hreflang}">
config.htmlTag_stdWrap.override.insertData = 1
config.htmlTag_stdWrap.dataWrap = <html lang="{siteLanguage:hreflang}">

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the codelines from Georg Ringer. I know too little of Integration with these codes, I am not sure what the reasoning was to use 'override' here, and if it would have benefits. Are you absolutely sure it would work with a dataWrap and has no side effects?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both are not working. My example will append an additional html-tag (which is wrong) and the one from Georg will remove all previously added html attributes and will not set the hreflang from site language. Instead it will show the hreflang from Locale object contained in SiteLanguage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so dump. If you work with:

config.htmlTag.attributes.class = specialHtmlTagClass

the solution from Georg will overwrite everything. So, this attribute is gone in Georgs solution. I remember some special tag properties from TypoScript. I tried with encapseLines, but as in $content <html lang="en_US"> is no ending <html> the tags property can not replace anything.

OK. I tries something very different: externalBlocks of parseFunc. It does not work either as HtmlParser_tags does not have stdWrap properties. So, I can also fixAttrib->set with fixed values.

So, currently only replacement seems to be an option:

config.htmlTag.attributes.garvin = hallo

config.htmlTag_stdWrap.replacement.10 {
  search = #lang="(.*?)"#i
  replace.dataWrap = lang="{SITE:languages.0.hreflang}"
  useRegExp = 1
}

Further problem is, that {siteLanguage:hreflang} will automatically be redirected into the sub-object Locale of Language object. But in Locale object still the original hreflang exists and not the modified version from Site Language object:

https://github.com/TYPO3/typo3/blob/main/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php#L4044-L4046

So, to get the hreflang property from Site Configuration (without Locale object) is to access all languages and extract the first one. See my example TS from above.

Is there anyone with another idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

override makes it already clear, that the tag is indeed overridden. If you want to have it fool proof add a comment that it is overriden and you might have to redefine other parameters. I would not use crazy constructs as most ppl hardly understand stdwrap.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have created an issue ticket: https://forge.typo3.org/issues/104987

@brotkrueml brotkrueml dismissed their stale review September 17, 2024 16:04

Open questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants