Language: lang-Attribute in <html>-Tag

Hi,
I can’t find the sting, why the «lang» attribute doesn’t appear in the <html>-Tag.

I found the Typo3.Neos.Seo/Resources/Private/TypoScript/Root.ts2

prototype(TYPO3.Neos:Page) {
	htmlTag {
		attributes {
			lang = ${String.replace(documentNode.context.dimensions.language[0], '_', '-')}
			lang.@if.languageDimensionExists = ${Configuration.setting('TYPO3.TYPO3CR.contentDimensions.language') != null}
			lang.@if.onlyRenderWhenInLiveWorkspace = ${node.context.workspace.name == 'live'}
		}
	}


I use this as a reference, but my

#root.ts2

page = Page {
	htmlTag{
		attributes{
			lang = 'en-US'
			class = 'hey'
		}
	}
...

doesn’t work properly. There is only this to find in sourceCode:

So the «class» attributes is working («hey» is in attribute class), but no «lang»-attribute to find.

Unfortunately I can not find a solution with Google or the forum-search:
Could someone push me to the right direction?

If you have the SEO package installed then the typoscript you mentioned for lang still applies, that means the two @if conditions will be applied to your lang attribute as well.

I suggest you clear the configuration before setting it:

lang >
lang = 'en-US'

Thank you @christianm,

I try it with:

page = Page {
	htmlTag{
		attributes{
			lang >
			lang = 'en-US'
			class = 'heby'
		}
	}
...

but no change, also after flush the cash.

I think with

[quote=“christianm, post:2, topic:1298”]
I suggest you clear the configuration
[/quote] you meant the «***lang >***»

Or do I misunderstood something?

You could still have a problem with the loading order then. If the Seo TS is loaded after yours then it will overwrite it of course. So you might want to check that.

Loading Order?

Did someone could help me to find the right path to the Loading Order?

In Package Management I could see

  • the «Typo3.Neos.Seo» package under tab «Application» and
  • my “vendor/base-neos-distribution” under tab «Sites», but no loading-Order-Number.
    In composer.json * under «root» there is:
{
  "name": "cleanAndClear/base-neos-distribution",
  "authors": [
    {
      "name": "My Name",
      "email": "email@email.com"
    }
  ],
  "config": {
    "vendor-dir": "Packages/Libraries",
    "bin-dir": "bin"
  },
  "repositories": [
    {
      "type": "git",
      "url": "https://userName:Password@bitbucket.org/packageName/base-neos-distribution.git"
    }
  ],
  "require": {
    "packageName/base-neos-distribution": "~0.0"
  },
  "scripts": {
    "post-update-cmd": "TYPO3\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
    "post-install-cmd": "TYPO3\\Flow\\Composer\\InstallerScripts::postUpdateAndInstall",
    "post-package-update": "TYPO3\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall",
    "post-package-install": "TYPO3\\Flow\\Composer\\InstallerScripts::postPackageUpdateAndInstall"
  }
}

In composer.json * under «root/Packages/Sites/Vendor.Site/» there is:

{
    "name": "packageName/base-neos-distribution",
    "type": "typo3-flow-site",
    "description": "Clean Neos Base Distribution",
    "require": {
        "typo3/neos-nodetypes": "~2.2",
        "typo3/neos": "~2.2",
        "typo3/neos-seo": "~1.0",
        "neos/redirecthandler-neosadapter": "~1.0",
        "neos/redirecthandler-databasestorage": "~1.0",
        "typo3/swiftmailer": "^5.4",
        "flowpack/simplesearch-contentrepositoryadaptor": "^1.3",
        "flowpack/simplesearch": "^1.3"
    },
    "autoload": {
        "psr-0": {
            "VendorName\\SiteName": "Classes"
        }
    }
}

###Questions:

  • Can I set the loading-sequence for the packages/sites somewhere in one this two files?
  • Maybe the “require”-stack: is the sequence by its own those in «root’s» composer.json is loaded before those in «Site’s» composer.json? So my «packageName/base-neos-distribution*» would load before Seo-Package, maybe. If yes, did someone know how I could change this?
  • Do I have to set or check it somewhere else?
  • Knows someone the particular documentation-part? I cant find it by the usual search-methods …

###* Info:
I have packed up all requires for a cleanAndClear (without demo and other unneeded packages) wrapped in my own package: «base-neos-package». Maybe this cause the Loading-Order-Problem?
Would be great, if I could still use this abstraction and maybe do an additional instruction in «/Packages/Sites/Vendor.Site/composer.json» to define the Loading-Order.

  • Is there a way to do this?

You might be experiencing this bug https://jira.neos.io/browse/NEOS-1821

The loading order should be correct since your site package composer.json requires the SEO package.

Here’s the two conditions on the lang property https://github.com/neos/neos-seo/blob/master/Resources/Private/TypoScript/Root.ts2#L9-L10

You could try setting

lang.@if.languageDimensionExists = {true}
lang.@if.onlyRenderWhenInLiveWorkspace = {true}

As a workaround to see if that helps.

1 Like

Hi @aertmann,
you are my hero :vulcan:.
If problems would always solve in that ease… would heavenly! :clap:

So, I guess it is your mentioned bug. To work around I did (only, that typos does not despair someone)

page = Page {
	htmlTag{
		attributes{
			lang >
			lang = 'en-US'
			#reset property lang with «lang >» doesn't work because of bug  https://jira.neos.io/browse/NEOS-1821 > so hardcode the two @if statements loan from Seo-Package > although one would be enough, but easier to understand 
			lang.@if.languageDimensionExists = ${true}
			lang.@if.onlyRenderWhenInLiveWorkspace = ${true}
		}
	}

And your work-around rocks:

Presumably I could delete the lang > if the problem is really owing the bug. But in future the bug will disappear and so, the code is easier to understand and adjust.

@aertmann: Thanks a lot!
Martin

1 Like