Skip to content

[4.2] mod_breadcrumbs. Fix several issues with ld+json structured data#38285

Merged
roland-d merged 7 commits intojoomla:4.2-devfrom
GHSVS-de:mod_breadcrumbs
Jul 29, 2022
Merged

[4.2] mod_breadcrumbs. Fix several issues with ld+json structured data#38285
roland-d merged 7 commits intojoomla:4.2-devfrom
GHSVS-de:mod_breadcrumbs

Conversation

@GHSVS-de
Copy link
Copy Markdown
Contributor

@GHSVS-de GHSVS-de commented Jul 16, 2022

Pull Request for Issue #38229

Fixes also: Position is wrongly set if the menu pathway for example contains Heading menu items.

Summary of Changes

  • Add a helper method getHome() that can be used without redundant code elsewhere to get the home item.
  • Only use $app->getLanguage() if needed.
  • Pick the home item ($homeCrumb) in mod_breadcrumbs.php if showHome is disabled.
  • default.php:
    • Use an independant counter for positions.
    • Always set an itemListElement for startpage even if showHome is disabled.
    • Only set <SCRIPT ld.json> if BraedCrumbList is populated.

Testing Instructions

  • Create a mod_breadcrumbs module. On all pages. Play around with the settings in the following.
  • Build a test scenario with different menu items, menu item types and different menu deepness. Use also menu items with type Heading in between.

The visible breadcrumb hasn't changed with this pr, only the ld+json part.

Either:

In frontend click through your menus and check the source code of displayed codes.
Search for ld+json to find a <script> tag like

<script type="application/ld+json">{"@context":"https:\/\/schema.org","@type":"BreadcrumbList","itemListElement":[...]}</script>

Or:

You can also use Browser Addons like "JSON-LD Tester" for chromium browsers (Chrome, Vivaldi ...) which uses Google testing tools.

Both:

  • Check that all menu items are present and represent the correct pathway of the current page.
  • Check that Heading menu items are not.
  • Check that parameters position go from 1 to x in +1 steps.
  • Check that start page (home) is always at position: 1.

Actual result BEFORE applying this Pull Request

  • Empty and invalid "itemListElement":[] on startpage if showHome is disabled in mod_breadcrumbs.
  • Wrong position steps if Heading menu items are present in menu.
  • Missing home entry on deeper pages (?? don't remember).

Expected result AFTER applying this Pull Request

No errors in structured data when testing.

Additional

A legend is going around that the last element must not have a @id (= forbidden) if it's the current page, which is wrong (I've tested that on several pages that use other tools for ld+json). Because I
don't want endless discussions here I've left the old behavior in mod_breadcrumbs (no @id for last element if it's current page).

GHSVS-de added 4 commits July 16, 2022 13:36
- Add a helper method getHome() that can be used without redundant code elsewhere.
- Get the home item ($homeCrumb) in mod_breadcrumbs.php if showHome is disabled.
- default.php:
- - Use an independant counter for positions.
- - Always set an itemListElement for startpage.
Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
@ChristineWk
Copy link
Copy Markdown

I have tested this item ✅ successfully on 8ac90ae


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38285.

1 similar comment
@viocassel
Copy link
Copy Markdown
Contributor

I have tested this item ✅ successfully on 8ac90ae


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38285.

@richard67
Copy link
Copy Markdown
Member

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/38285.

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jul 17, 2022
@roland-d roland-d merged commit 05fa4fb into joomla:4.2-dev Jul 29, 2022
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jul 29, 2022
@roland-d
Copy link
Copy Markdown
Contributor

Thank you

@roland-d roland-d added this to the Joomla! 4.2.0 milestone Jul 29, 2022
@GHSVS-de GHSVS-de deleted the mod_breadcrumbs branch July 29, 2022 21:30
brianteeman pushed a commit to brianteeman/joomla-cms that referenced this pull request Aug 2, 2022
joomla#38285)

* Fix position counter and get home item always.

- Add a helper method getHome() that can be used without redundant code elsewhere.
- Get the home item ($homeCrumb) in mod_breadcrumbs.php if showHome is disabled.
- default.php:
- - Use an independant counter for positions.
- - Always set an itemListElement for startpage.

* Code style mod_breadcrumbs.php

* Code style BreadcrumbsHelper.php

* codestyle default.php

* Typo headline versus Heading

* Update modules/mod_breadcrumbs/tmpl/default.php

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
rdeutz pushed a commit to joomla-projects/joomla-cms that referenced this pull request Aug 8, 2022
joomla#38285)

* Fix position counter and get home item always.

- Add a helper method getHome() that can be used without redundant code elsewhere.
- Get the home item ($homeCrumb) in mod_breadcrumbs.php if showHome is disabled.
- default.php:
- - Use an independant counter for positions.
- - Always set an itemListElement for startpage.

* Code style mod_breadcrumbs.php

* Code style BreadcrumbsHelper.php

* codestyle default.php

* Typo headline versus Heading

* Update modules/mod_breadcrumbs/tmpl/default.php

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>

Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants