Closed (fixed)
Project:
Office Hours
Version:
8.x-1.5
Component:
Code - formatter
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
15 Apr 2021 at 15:18 UTC
Updated:
4 Jan 2022 at 16:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
johnvComment #3
johnvComment #4
johnvComment #5
splash112 commentedChecked a bit and it seems that everything is ready, except nicely formatted (day and time) tokens from Office Hours module.
Looking into that.
Comment #6
johnvComment #7
johnvPlease also check the reference issue #2109699: Add schema.org/openingHours(Specification) microdata for office_hours [META] (+D7 patch).
Reason for not having implemented this, are the several doubts I have and the several formatting systems that exist out there.
Comment #8
splash112 commentedFirst stab. Adding a office_hours.token.inc file which displays the tokens as full weekdays and html time.
Displays and confirms with Google Schema.org metatags (as long you one uses a short and simple office_hour field.
Comment #9
splash112 commentednow with patch that is not empty...
Comment #10
johnv@splash112,
are you working in the correct ticket? The Token issue is #1848750: Add Token support.
This issue is about schema.org metatags.
Comment #11
johnv@splash112,
Oh, I see you are referring to that in your comment. How are both connected? There is no schema.org support yet.
Comment #12
splash112 commentedHi @johnv,
Thanks for the quick response.
There are multiple ways to implement schema.org tags. Looks like you have been working mostly inline.
One of the other ways is via JSON-LD script (Google preferred) in the metatags. The patch supplies the tokens for Metatag module to output the correct tags.
It works, but only in the most straightforward use case (the only one accepted by Google I think).
Comment #13
splash112 commentedOutputs something like above. So yes, a nice cross between Token, Schema.org and Metatag.
Comment #14
johnvThe token file works fine to generate tokens. (I tested with Automatic Entity Label).
I will commit it in the other ticket.
There are several parts in the code to prepare for Schema.org, in an attempt to add out-of-the box support, without use of other modules, since this fits 1-to-1 to a schema.org property:
- In the formatter settings:
SCHEMA.ORG OPENINGHOURS SUPPORT
[X] Enable Schema.org openingHours support (Enable meta tags with property for Schema.org openingHours.)
- function template_preprocess_office_hours() contains a schema part.
- file OfficeHoursFormatterSchema.php contains a formatter which is used if above checkmark is set.
Do you think this is not needed?
Comment #15
johnvPlease also check the long-time Meta issue #2109699: Add schema.org/openingHours(Specification) microdata for office_hours [META] (+D7 patch)
Comment #16
johnvYour patch is committed here: #1848750-5: Add Token support
Comment #17
splash112 commentedOh, maybe a bit premature to commit... Not sure what will happen with multiple value fields, etc.
The date formats are now hardcoded. Might be better to either make them configurable or supply multiple.
Comment #18
splash112 commentedDamn, exported the config from my local (and working like expected) site to production and the output went bad. Somehow the day moved down a day. (times for Friday are show as Thursday.
Will look into it.
Comment #19
splash112 commentedThis patch should fix it
Comment #21
johnvYour fix was commtted in a slightly different way. See attached patch.
Comment #22
splash112 commentedThanks!
Comment #23
gumanist commentedI have updated the patch to support multivalues and a single item with 'pivot' option in metagag.
Usage:
1. [node:field:property] - all properties with ',' delimiter
2. [node:field:{delta}:property
Examples:
[node:field:day] -> Monday,Wednesday
[node:field:0:day] -> Monday
Comment #24
gumanist commentedChanged status to Needs review
Comment #25
andypostshould be s
witch ($property)insteadComment #26
gumanist commentedUpdated $property and removed unnecessary line
Comment #27
andypostIt could use tests but it will be tricky to setup
Comment #28
dmitriy.trt commentedLatest patch (#26) didn't apply for me. Attaching an updated one and an interdiff.
Changes on top of #26:
day-untranslatedtoken, so that days of week never get translated in the metadata. I'm not 100% sure if it violates the standard, but Google readsMondayashttp://schema.org/MondayandПонедельник(which is "Monday" in Russian) as-is, so it may be a good idea to always use untranslated day names.Comment #29
dmitriy.trt commentedComment #30
dmitriy.trt commentedAttaching a version that applies to 8.x-1.5 stable version, just in case it's useful for somebody. Otherwise, please ignore it.
Comment #31
dmitriy.trt commentedOne more update on top of #28 to keep the
$day_namesvariable name introduced by this commit.Comment #33
johnvThanks all, committed.
However, It is nice to have (general) token support in this module, but can someone please explain to me how this helps "Add schema.org/OpeningHoursSpecification microdata"?
Comment #34
splash112 commentedNow you can easily add the opening hours to your metatags as structured data. See image attached.
Comment #35
johnvThanks,
It seems the above is the result. But how to add this? Is it accessible for a 'normal' sitebuilder using the Drupal UI?
See also my doubts/lack of knowledge on the several formats in #2109699: Add schema.org/openingHours(Specification) microdata for office_hours [META] (+D7 patch).
Ideally, it should work out of the box with a FieldFormatter.
Comment #36
gumanist commentedSee an example of metatag configuration:
Second 'dayOfWeek' is typo in metatag module. Should read as 'closes'
Comment #37
johnvThanks, but still cannot find it.
I added a Metatag reference on the project page.
The openingHoursSpecification functionality can benefit from #1998266: Add "Exception day" feature
The openingHours metadata was WIP and is now implemented here: #2720335: Add schema.org/openingHours Microdata, RDFa (D8)
Comment #38
splash112 commentedThanks! It's part of the organization schema metatags.
Comment #39
johnvThanks, I missed that. Added to the ticket and the project page.