2

I want to add <meta> and <link> tags in the source code from TinyMCE to add schema.org declarations.

  • Tiny MCE is set to use the filter from Joomla.
  • The Joomla textfilter is set to "No Filtering".
  • I can use <iframe> in the source code of MCE, so the "No Filtering" looks like is working. <iframe> is on the default Blacklist.

However, if I add <meta> or <link> to the source code containing schema.org declarations, Tiny MCE removes the tags after switch from "Source Code Editor" back to "WYSIWYG" and vice versa.

2

Here is my solution:
At first: remove meta and link from the source code is not part of the joomla filter. it is part of the core. So modify the core is not a solution about problem with later updates.

Second: the third part component sourcer can work but it is a third part solution out of my control for validation and verification. And every additional component needs performance.

So I’m looking for a solution which joomla brings out of the box.

tl;dr

I used custom fields with a layout override.

Here a sample what and why I want to add:

<figure  itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
<meta itemprop="representativeOfPage" content="true">
<link itemprop="url" href="https://www.usa-reisetipps.net/images/bilder/ein-ausreise/visum-esta-16x9.jpg">
<link itemprop="url" href="https://www.usa-reisetipps.net/images/bilder/ein-ausreise/visum-esta-4x3.jpg">
<link itemprop="url" href="https://www.usa-reisetipps.net/images/bilder/ein-ausreise/visum-esta-1x1.jpg">
<link itemprop="url" href="https://www.usa-reisetipps.net/images/bilder/ein-ausreise/visum-esta.jpg">
<amp-img src="/images/bilder/ein-ausreise/visum-esta.jpg" width="750" height="423" layout="responsive" srcset="/images/bilder/ein-ausreise/visum-esta.jpg 750w, /images/bilder/ein-ausreise/visum-esta-768.jpg 558w, /images/bilder/ein-ausreise/visum-esta-480.jpg 413w" alt="alt text"></amp-img>  
<figcaption itemprop="description caption">Caption text.</figcaption>
</figure>

Here are the steps:

  • Create a own layout for fields (meta): create a override for fields layout

In this file I change the line

echo htmlentities($value);

to

echo $value;

to print the meta and not a html version

  • I create a custom filed with text (one line add) or textarea (bigger source code) for the snippet: create a custom filed as text or textarea

Important the field shall have:
filter: unfiltered and the selected layout

select no filter for the field input

select the verride in this case meta

Add my meta and links:

fill the fields with my meta or links tag I added the field to the article with:

{field 2}
0
+50

TinyMCE settings can be configured at Extensions -> Plugins -> Editor - TinyMCE including enabling HTML elements which may not strictly conform to HTML4 or HTML5 standards by adding these to the "Valid Elements" or "Extended Valid Elements" fields (see below) although meta data is usually added to the <head> area rather than the <body> area of an HTML page.

TinyMCE Settings

A better solution might be to use Regular Labs Sourcerer or similar to insert the appropriate PHP code into the content to add the declarations to the <head> area of the HTML page.

See setMetaData and addCustomTag for example PHP code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.