{"id":19784324,"url":"https://github.com/alexprut/plg_system_microdata","last_synced_at":"2025-04-30T22:32:06.700Z","repository":{"id":19060026,"uuid":"22286547","full_name":"alexprut/plg_system_microdata","owner":"alexprut","description":"Joomla System Plugin for parsing the HTML markup and convert the data-* HTML5 attributes in Microdata semantics.","archived":true,"fork":false,"pushed_at":"2020-06-08T16:13:32.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-28T13:21:22.687Z","etag":null,"topics":["joomla","joomla-plugin","microdata","schema-org"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexprut.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-26T12:54:37.000Z","updated_at":"2024-02-13T21:35:24.000Z","dependencies_parsed_at":"2022-09-02T06:30:59.258Z","dependency_job_id":null,"html_url":"https://github.com/alexprut/plg_system_microdata","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexprut%2Fplg_system_microdata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexprut%2Fplg_system_microdata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexprut%2Fplg_system_microdata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexprut%2Fplg_system_microdata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexprut","download_url":"https://codeload.github.com/alexprut/plg_system_microdata/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251791742,"owners_count":21644448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["joomla","joomla-plugin","microdata","schema-org"],"created_at":"2024-11-12T06:11:11.515Z","updated_at":"2025-04-30T22:32:06.453Z","avatar_url":"https://github.com/alexprut.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Microdata\n=========\nA Joomla ```3.2+``` system plugin that uses the [JMicrodata](https://github.com/joomla/joomla-cms/tree/master/libraries/joomla/microdata \"JMicrodata\") library.  \nCreated during the Google Summer of Code 2014.\n\nIf you want to keep your views separated from the logic, ```plg_system_microdata``` is a system plugin for parsing the HTML markup and converting the ```data-*``` HTML5 attributes into the correctly formatted Microdata syntax.  \n\nThe ```data-*``` attributes are new in HTML5, they give us the ability to embed custom data attributes on all HTML elements. So if you disable the library output, the HTML will still be validated. The default suffix that the library will search for is ```data-sd```, where sd stands for structured data, but you can register more than one custom suffix.  \n\nInstallation\n============\n[Download the last version of the plugin](https://github.com/alexprut/plg_system_microdata/archive/master.zip \"Download plg_system_microdata\") and install it. __Don't forget to publish this plugin!__\n\nUsage\n=====\nSince the system plugin runs immediately before the final content is sent to the client, you can use the plugin syntax everywhere, including native and third-party extensions that allow HTML editing.\n\n### Markup Syntax\n##### setType\n![ParserPlugin Syntax](https://alexprut.github.io/PHPStructuredData/images/parser-plugin-syntax-v1.3.0-setType.png)  \nThe _type_ defines which schema is being used for the following markup.  The Type must always have the first character Uppercase to be correctly interpreted. If the type is a valid schema, the global scope for the page from this point onwards is updated to this schema. The plugin will replace the data tag with ```itemscope itemtype='https://schema.org/Type'```.  \n  \n###### Example:\n```html\n\u003cdiv data-sd=\"Article\"\u003e\n    \u003cp\u003eThis is my article\u003c/p\u003e\n\u003c/div\u003e\n```\n\nThis will be output:\n```html\n\u003cdiv itemscope itemtype=\"http://schema.org/Article\"\u003e\n    \u003cp\u003eThis is my article\u003c/p\u003e\n\u003c/div\u003e\n```\n\n##### Specifying generic item properties\n![ParserPlugin Syntax](https://alexprut.github.io/PHPStructuredData/images/parser-plugin-syntax-v1.3.0-global.png)  \nOnce a schema has been declared, the next step is to declare individual properties – explaining the content and giving it semantic meaning.\n  \nThe _property_ must always have the first character as lowercase to be correctly interpreted. If the property is found to be part of the current schema, the plugin will replace the data tag with ```itemprop='property'```.  If the property is not found to be a valid property of the active schema, it will be ignored and the next available property will be parsed.\n\n###### Example:\n```html\n\u003cdiv data-sd=\"Article\"\u003e\n    \u003cp data-sd=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n\u003c/div\u003e\n```\n\nThis will be output:\n```html\n\u003cdiv itemscope itemtype=\"http://schema.org/Article\"\u003e\n    \u003cp itemprop=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n\u003c/div\u003e\n```\n\n##### Specifying schema—dependant item properties\n![ParserPlugin Syntax](https://alexprut.github.io/PHPStructuredData/images/parser-plugin-syntax-v1.3.0-specialized.png)  \nSometimes you may want to explicitly state a property which should only be used when a specific schema is active – for example, if the property has a specific property in one schema, which is called something different in another schema.\n\nIt is possible to achieve this by using a schema–dependant property.  This works by using a combination between both _Type_ and _property_, separated by a full stop. In short, if the current global scope is equal to Type and the property is part of that Type, the plugin will replace the data tag with ```itemprop='property'```.\n\n###### Example:\n```html\n\u003cdiv data-sd=\"Article\"\u003e\n    \u003cp data-sd=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n    \u003cp data-sd=\"Article.wordcount\"\u003e4\u003c/p\u003e\n\u003c/div\u003e\n```\n\nThis will be output:\n```html\n\u003cdiv itemscope itemtype=\"http://schema.org/Article\"\u003e\n    \u003cp itemprop=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n    \u003cp itemprop=\"wordcount\"\u003e4\u003c/p\u003e\n\u003c/div\u003e\n```\n\n### Using multiple properties\n![ParserPlugin Syntax](https://alexprut.github.io/PHPStructuredData/images/parser-plugin-syntax-v1.3.0.png)  \nIt is possible, using a combination of these, to specify multiple properties including some which are specific for a schema and others which are generic. The order of the building blocks isn't significant and a white space is used as a separator.\n\n###### Example:\n```html\n\u003cdiv data-sd=\"Article\"\u003e\n    \u003cp data-sd=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n    \u003cp data-sd=\"Article.wordcount\"\u003e4\u003c/p\u003e\n    \u003cp data-sd=\"Recipe.recipeCategory Article.articleSection description\"\u003eAmazing dessert recipes\u003c/p\u003e\n\u003c/div\u003e\n```\n\nThis will be output:\n```html\n\u003cdiv itemscope itemtype=\"http://schema.org/Article\"\u003e\n    \u003cp itemprop=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n    \u003cp itemprop=\"wordcount\"\u003e4\u003c/p\u003e\n    \u003cp itemprop=\"articleSection\"\u003eAmazing dessert recipes\u003c/p\u003e\n\u003c/div\u003e\n```\n\n##### Nesting schemas\nSometimes it is necessary to nest schemas – for example if you want to describe a person when you have the Article schema open. This is possible using nested schemas. To use this, simply append the schema preceeded by a full stop, __after__ the property.  Once you have finished using the nested schema, close the containing tag, and re-set the original schema.\n\n###### Example:\n```html\n\u003cdiv data-sd=\"Article\"\u003e\n    \u003cp data-sd=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n    \u003cp data-sd=\"Article.wordcount\"\u003e4\u003c/p\u003e\n    \u003cdiv data-sd=\"author.Person\"\u003e\n        \u003cp data-sd=\"name\"\u003eJohn Doe\u003c/p\u003e\n    \u003c/div\u003e\n    \u003cp data-sd=\"Article keywords\"\u003eCake\u003c/p\u003e\n\u003c/div\u003e\n```\n\nThis will be output:\n```html\n\u003cdiv itemscope itemtype=\"http://schema.org/Article\"\u003e\n    \u003cp itemprop=\"articleBody\"\u003eThis is my article\u003c/p\u003e\n    \u003cp itemprop=\"wordcount\"\u003e4\u003c/p\u003e\n    \u003cdiv itemprop=\"author\" itemscope itemtype=\"http://schema.org/Person\"\u003e\n        \u003cp itemprop=\"name\"\u003eJohn Doe\u003c/p\u003e\n    \u003c/div\u003e\n    \u003cp itemprop=\"keywords\"\u003eCake\u003c/p\u003e\n\u003c/div\u003e\n```\n\n##### The Algorithm:\n1. First the parser checks for __setTypes__. If one or more matches are found then the current global scope will be updated with the first match. At this point if there are no specific or generic properties the algorithm will finish and replace the data tag with the specified scope. Otherwise continue to point 2.\n2. The parser checks for __specific item properties__. If one or more valid matches are found, then the algorithm will finish and replace the data tag with the first match property. Otherwise go to point 3\n3. The parser checks for __generic properties__. If one or more valid matches are found, then the algorithm will replace the data tag with the first property that is matched, and complete the algorithm.\n\nSemantically marking up 'on the fly' within HTML editors\n========================================================\nTo apply markup within articles simply use the data tag and the method explained above.  \nSee below for an example.  \n![plg_system_structureddata content editor usage](https://alexprut.github.io/plg_system_structureddata/images/plg_system_structureddata-editor.png)  \n\nIncorporating into your extensions and templates\n================================================\nLet's suppose that somewhere in your code you need to add Microdata semantics to the following HTML which is part of an article (_e.g._ ```$scope='Article';```).\n```html\n\u003cdiv data-sd=\"\u003c?php echo $scope;?\u003e\"\u003e\n    \u003c!-- Title --\u003e\n    \u003cspan data-sd=\"Review.itemReviewed name\"\u003e\n        How to Tie a Reef Knot\n    \u003c/span\u003e\n    \u003c!-- Author --\u003e\n    \u003cspan\u003e\n        Written by\n        \u003cspan data-sd=\"author.Person\"\u003e\n            \u003cspan data-sd=\"name\"\u003eJohn Doe\u003c/span\u003e\n        \u003c/span\u003e\n    \u003c/span\u003e\n    \u003c!-- Date published --\u003e\n    \u003cmeta data-sd='\u003c?php echo $scope;?\u003e datePublished' content='2014-01-01T00:00:00+00:00'/\u003e1 January 2014\n    \u003c!-- Content --\u003e\n    \u003cspan data-sd='reviewBody articleBody'\u003e\n        Lorem ipsum dolor sit amet...\n    \u003c/span\u003e\n\u003cdiv\u003e\n```\nThe output will be:\n```html\n\u003cdiv itemscope itemtype='https://schema.org/Article'\u003e\n    \u003c!-- Title --\u003e\n    \u003cspan itemprop='name'\u003e\n        How to Tie a Reef Knot\n    \u003c/span\u003e\n    \u003c!-- Author --\u003e\n    \u003cspan\u003e\n        Written by\n        \u003cspan itemprop='author' itemscope itemtype='https://schema.org/Person'\u003e\n            \u003cspan itemprop='name'\u003eJohn Doe\u003c/span\u003e\n        \u003c/span\u003e\n    \u003c/span\u003e\n    \u003c!-- Date published --\u003e\n    \u003cmeta itemprop='datePublished' content='2014-01-01T00:00:00+00:00'/\u003e1 January 2014\n    \u003c!-- Content --\u003e\n    \u003cspan itemprop='articleBody'\u003e\n        Lorem ipsum dolor sit amet...\n    \u003c/span\u003e\n\u003cdiv\u003e\n```\n\nInstead, if you decide to change the current Type (_e.g._ ```$scope=\"Review\";```).  \nThe output will be:\n```html\n\u003cdiv itemscope itemtype='https://schema.org/Review'\u003e\n    \u003c!-- Title --\u003e\n    \u003cspan itemprop='itemReviewed'\u003e\n        How to Tie a Reef Knot\n    \u003c/span\u003e\n    \u003c!-- Author --\u003e\n    \u003cspan\u003e\n        Written by\n        \u003cspan itemprop='author' itemscope itemtype='https://schema.org/Person'\u003e\n            \u003cspan itemprop='name'\u003eJohn Doe\u003c/span\u003e\n        \u003c/span\u003e\n    \u003c/span\u003e\n    \u003c!-- Date published --\u003e\n    \u003cmeta itemprop='datePublished' content='2014-01-01T00:00:00+00:00'/\u003e1 January 2014\n    \u003c!-- Content --\u003e\n    \u003cspan itemprop='reviewBody'\u003e\n        Lorem ipsum dolor sit amet...\n    \u003c/span\u003e\n\u003cdiv\u003e\n```\n\nLicense\n-------\nplg_system_microdata is licensed under the GNU GPL v2 License – see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexprut%2Fplg_system_microdata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexprut%2Fplg_system_microdata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexprut%2Fplg_system_microdata/lists"}