Embed Microdata

How to embed Microdata for templates developed with T3 framework

T3 Bootstrap 2 version

Microdata is used to nest metadata within existing content on a web page.

Wikipedia

In short, it enables your Joomla site content to be more SEO-optimized content than it is and allows your Joomla CMS to explain itself to the search engine using the semantic information. Often you might have heard microdata by its other familiar name: Rich Snippets.

With the implementation of microdata, you’ll have the benefit of a “restructured” content where it clearly defines the content’s type, author, rating, etc. for the search engines, web crawlers and browsers can pick up it to ensure a richer web browsing experience to users.

Embed microdata

Microdata is first introduced in Joomla 3.3. Once you upgrade/install Joomla 3.3, microdata is activated by default. There isn’t any given configuration option to disable this, as they are hard-coded. All the markup are structured according to the schema.org markup. It is much longer and contains specific properties indicate what the content is about.

If you would want to see how your site’s microdata look like, check its source code. Check following example.

<div class="well "><h3 class="page-header">Latest Articles</h3><ul class="latestnews">
	<li itemscope itemtype="http://schema.org/Article">
		<a href="/joomla-fresh/Joomla_3.3.0-Stable-Full_Package/" itemprop="url">
			<span itemprop="name">Getting Started</span></a>
	</li>
</ul>
</div>

While in Joomla 3.2, it would be:

<div class="well "><h3 class="page-header">Latest Articles</h3><ul class="latestnews">
	<li>
		<a href="/joomla-fresh/Joomla_3.2.0-Stable-Full_Package/">
			Getting Started</a>
	</li>
</ul>
</div>
View microdata in source

There isn’t any Microdata for me

If you can’t be able to find any trace of microdata on your Joomla, that can probably be resulted a template override. In order to double check on this, you would need to look up in your template folder to see whether or not there is an override for com_content article. If there are, you have to remove this override or for the simpler step: ask your template provider to do it for you or wait for the upgrade version of Joomla 3.3 for your template.

Don’t feel like upgrading to Joomla 3.3 but still want to get microdata integrated into your Joomla site? The Joomla template framework - T3 version 2.2 has your back. It embedded Microdata at core and no matter you are working on either Joomla 2.5 or Joomla 3, you’ll still can get the Microdata benefit from this release.

We bring microdata declaration from Joomla 3.3 into T3 core (in default layouts of T3 framework - plugins\system\t3\base-bs3\html\com_content and plugins\system\t3\base\html\com_content) following the markup structure of schema.org markup. On top of that, we also define the markup for microdata for each layout, by that, it means the microdata markup in different layouts can be different. The default layouts are also restructured.

Article layout: plugins\system\t3\base-bs3\html\com_content\article\default.php

<!-- Article -->
<article itemscope itemtype="http://schema.org/Article">
	<meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*') ? JFactory::getConfig()->get('language') : $this->item->language; ?>" />

<?php if ($params->get('show_title')) : ?>
	<?php echo JLayoutHelper::render('joomla.content.item_title', array('item' => $this->item, 'params' => $params, 'title-tag'=>'h1')); ?>
<?php endif; ?>

<!-- Aside -->
<?php if ($topInfo || $icons) : ?>
<aside class="article-aside clearfix">
  <?php if ($topInfo): ?>
  <?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'position' => 'above')); ?>
  <?php endif; ?>
  
  <?php if ($icons): ?>
  <?php echo JLayoutHelper::render('joomla.content.icons', array('item' => $this->item, 'params' => $params)); ?>
  <?php endif; ?>
</aside>  
<?php endif; ?>
<!-- //Aside -->

Featured layout: plugins\system\t3\base-bs3\html\com_content\featured\default.php

<div class="blog-featured<?php echo $this->pageclass_sfx;?>" itemscope itemtype="http://schema.org/Blog">
<?php if ($this->params->get('show_page_heading') != 0) : ?>
<div class="page-header">
	<h1>
	<?php echo $this->escape($this->params->get('page_heading')); ?>
	</h1>
</div>
<?php endif; ?>

<?php $leadingcount = 0; ?>
<?php if (!empty($this->lead_items)) : ?>
<div class="items-leading clearfix">
	<?php foreach ($this->lead_items as &$item) : ?>
		<div class="leading leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>"
				itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
			<?php
				$this->item = &$item;
				echo $this->loadTemplate('item');
			?>
		</div>
		<?php
			$leadingcount++;
		?>
	<?php endforeach; ?>
</div>
<?php endif; ?>
<?php
	$introcount = (count($this->intro_items));
	$counter = 0;
?>
<?php if (!empty($this->intro_items)) : ?>
	<?php foreach ($this->intro_items as $key => &$item) : ?>

		<?php
		$key = ($key - $leadingcount) + 1;
		$rowcount = (((int) $key - 1) % (int) $this->columns) + 1;
		$row = $counter / $this->columns;

		if ($rowcount == 1) : ?>

		<div class="items-row cols-<?php echo (int) $this->columns;?> <?php echo 'row-'.$row; ?> row">
		<?php endif; ?>
			<div class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?> col-sm-<?php echo round((12 / $this->columns));?>"
				itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
			<?php
				$this->item = &$item;
				echo $this->loadTemplate('item');
			?>
			</div>
			<?php $counter++; ?>

			<?php if (($rowcount == $this->columns) or ($counter == $introcount)) : ?>

		</div>
		<?php endif; ?>

	<?php endforeach; ?>
<?php endif; ?>

What info included in the Microdata?

by default, we have following microdata content type:

  • Article
  • Blog
  • Post
  • Person
For each content type, it has multiple info:
  • Title
  • Author
  • URL
  • Published date
  • Category
  • Article body
  • Thumbnail image url
  • Hits

You can use the Google Structure Data testing tool to check how microdata of pages in your site are displayed. The following sample gives you an overview of Microdata:

Article single microdata

Each template has multiple layouts, those layouts are overridden from default layouts of T3 framework. So to have microdata active for those overridden layouts, we need to declare microdata markup in the layout files. All the override layouts of template are located in templates/ja_template/html/com_content/.

T3 microdata embed

All templates developed with T3 Framework will be upgraded to be compatible with Joomla 3 and Microdata will be embeded. If you want to have Microdata enabled, please upgrade T3 framework and template. Please take full backup before upgrading. We suggest to use JA Extension Manager to upgrade. Check out the detailed upgrade documentation at: http://t3-framework.org/documentation/installation#upgrade.

If you don't want to upgrade template or you customized layouts a lot or you created your own layouts, you can embed Microdata manually for those layouts.

Requirement:

It is only for T3 templates - templates developed with T3 Framework and you have to upgrade T3 framework to version 2.2+ as the version has microdata embeded, otherwise, it does not work.

Open the override layout files of T3 template: templates/ja_template/html/com_content/, find and replace the following codes in the layout files. You can also check the default layouts in: plugins\system\t3\base-bs3\html\com_content\ to see how they are changed and add changes back to your template layout files.

Embed microdata manually

Article

You might see the info in the following files:

Replace

<article>

with:

<article itemscope itemtype="http://schema.org/Article">
	<meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*') ? JFactory::getConfig()->get('language') : $this->item->language; ?>" />

Article title

Replace

<?php if ($params->get('show_title')) : ?>
	<header class="article-header clearfix">
		<h1 class="article-title">
			<?php if ($params->get('link_titles') && !empty($this->item->readmore_link)) : ?>
				<a href="/<?php echo $this->item->readmore_link; ?>"> <?php echo $this->escape($this->item->title); ?></a>
			<?php else : ?>
				<?php echo $this->escape($this->item->title); ?>
			<?php endif; ?>
		</h1>
	</header>
<?php endif; ?>

with:

<?php if ($params->get('show_title')) : ?>
	<?php echo JLayoutHelper::render('joomla.content.item_title', array('item' => $this->item, 'params' => $params, 'title-tag'=>'h1')); ?>
<?php endif; ?>

Aside

Redefine condition

Replace

$aInfo    = (($params->get('show_author') && !empty($this->item->author)) ||
			($params->get('show_category')) ||
			($params->get('show_create_date')) ||
			($params->get('show_parent_category')) ||
			($params->get('show_publish_date')));

$exAction = ($canEdit ||
			$params->get('show_print_icon') ||
			$params->get('show_email_icon'));

with:

$topInfo = ($aInfo1 && $info != 1) || ($aInfo2 && $info == 0);
$icons = !empty($this->print) || $canEdit || $params->get('show_print_icon') || $params->get('show_email_icon');

Restructure aside

Replace

<?php if ($aInfo || $exAction) : ?>
	<!-- Aside -->
	<aside class="article-aside clearfix">

		<?php if ($aInfo) : ?>
			<dl class="article-info pull-left">
				<dt class="article-info-term"><?php echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?></dt>

				<?php if ($params->get('show_author') && !empty($this->item->author)) : ?>
					<dd class="createdby">
						<?php
						$author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author;
						?>
						<?php if (!empty($this->item->contactid) && $params->get('link_author') == true): ?>
							<?php
							$needle = 'index.php?option=com_contact&view=contact&id=' . $this->item->contactid;
							$menu = JFactory::getApplication()->getMenu();
							$item = $menu->getItems('link', $needle, true);
							$cntlink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
							?>
							<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', '<strong>' . JHtml::_('link', JRoute::_($cntlink), $author) . '</strong>'); ?>
						<?php else: ?>
							<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', '<strong>' . $author . '</strong>'); ?>
						<?php endif; ?>
					</dd>
				<?php endif; ?>

				<?php if ($params->get('show_publish_date')) : ?>
					<dd class="published">
						<?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE_ON', '<strong>' . JHtml::_('date', $this->item->publish_up, JText::_('DATE_FORMAT_LC3')) . '</strong>'); ?>
					</dd>
				<?php endif; ?>

				<?php if ($params->get('show_create_date')) : ?>
					<dd class="create">
						<?php echo JText::sprintf('COM_CONTENT_CREATED_DATE_ON', '<strong>' . JHtml::_('date', $this->item->created, JText::_('DATE_FORMAT_LC3')) . '</strong>'); ?>
					</dd>
				<?php endif; ?>

				<?php if ($params->get('show_parent_category') && $this->item->parent_slug != '1:root') : ?>
					<dd class="parent-category-name">
						<?php
						$title = $this->escape($this->item->parent_title);
						$url = '<a href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->parent_slug)) . '">' . $title . '</a>';
						?>
						<?php if ($params->get('link_parent_category') and $this->item->parent_slug) : ?>
							<?php echo JText::sprintf('COM_CONTENT_PARENT', '<strong>' . $url . '</strong>'); ?>
						<?php else : ?>
							<?php echo JText::sprintf('COM_CONTENT_PARENT', '<strong>' . $title . '</strong>'); ?>
						<?php endif; ?>
					</dd>
				<?php endif; ?>

				<?php if ($params->get('show_category')) : ?>
					<dd class="category-name">
						<?php    $title = $this->escape($this->item->category_title);
						$url = '<a href="' . JRoute::_(ContentHelperRoute::getCategoryRoute($this->item->catslug)) . '">' . $title . '</a>';?>
						<?php if ($params->get('link_category') and $this->item->catslug) : ?>
							<?php echo JText::sprintf('COM_CONTENT_CATEGORY', '<strong>' . $url . '</strong>'); ?>
						<?php else : ?>
							<?php echo JText::sprintf('COM_CONTENT_CATEGORY', '<strong>' . $title . '</strong>'); ?>
						<?php endif; ?>
					</dd>
				<?php endif; ?>
			</dl>
		<?php endif; ?>

		<?php if ($exAction) : ?>
			<div class="btn-group pull-right">
				<a class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="#"> <i class="fa fa-cog"></i>
					<span class="caret"></span> </a>
				<ul class="dropdown-menu">
					<?php if (!$this->print) : ?>
						<?php if ($params->get('show_print_icon')) : ?>
							<li class="print-icon"> <?php echo JHtml::_('icon.print_popup', $this->item, $params); ?> </li>
						<?php endif; ?>
						<?php if ($params->get('show_email_icon')) : ?>
							<li class="email-icon"> <?php echo JHtml::_('icon.email', $this->item, $params); ?> </li>
						<?php endif; ?>
						<?php if ($canEdit) : ?>
							<li class="edit-icon"> <?php echo JHtml::_('icon.edit', $this->item, $params); ?> </li>
						<?php endif; ?>
					<?php else : ?>
						<li> <?php echo JHtml::_('icon.print_screen', $this->item, $params); ?> </li>
					<?php endif; ?>
				</ul>
			</div>
		<?php endif; ?>
	</aside>
	<!-- //Aside -->
<?php endif; ?>

with:

<!-- Aside -->
<?php if ($topInfo || $icons) : ?>
<aside class="article-aside clearfix">
  <?php if ($topInfo): ?>
  <?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'position' => 'above')); ?>
  <?php endif; ?>
  
  <?php if ($icons): ?>
  <?php echo JLayoutHelper::render('joomla.content.icons', array('item' => $this->item, 'params' => $params)); ?>
  <?php endif; ?>
</aside>  
<?php endif; ?>
<!-- //Aside -->

Show tag

Replace

<?php if ($params->get('show_tags', 1) && !empty($this->item->tags)) : ?>
	<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>

	<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
<?php endif; ?>

with:

<?php if ($params->get('show_tags', 1) && !empty($this->item->tags)) : ?>
	<?php echo JLayoutHelper::render('joomla.content.tags', $this->item->tags->itemTags); ?>
<?php endif; ?>

Blog layout

Replace

<div class="blog<?php echo $this->pageclass_sfx;?>">

with:

<div class="blog<?php echo $this->pageclass_sfx;?>" itemscope itemtype="http://schema.org/Blog">

Item leading

Replace

<div class="leading leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">

with:

<div class="leading leading-<?php echo $leadingcount; ?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>"
		 itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">

Featured item layout

Replace

<div class="blog-featured<?php echo $this->pageclass_sfx;?>">

with:

<div class="blog-featured<?php echo $this->pageclass_sfx;?>" itemscope itemtype="http://schema.org/Blog">

Article intro

Replace

<section class="article-intro clearfix">

with:

<section class="article-intro clearfix" itemprop="articleBody">

Footer

Replace

<?php if (($params->get('show_modify_date')) or ($params->get('show_hits'))) : ?>
	<footer class="article-footer clearfix">
		<dl class="article-info pull-left">
			<?php if ($params->get('show_modify_date')) : ?>
				<dd class="modified"><?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED', '<strong>' . JHtml::_('date', $this->item->modified, JText::_('DATE_FORMAT_LC3')) . '</strong>'); ?> </dd>
			<?php endif; ?>
			<?php if ($params->get('show_hits')) : ?>
				<dd class="hits"><?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS', '<strong>' . $this->item->hits . '</strong>'); ?> </dd>
			<?php endif; ?>
		</dl>
	</footer>
<?php endif; ?>

with:

<!-- footer -->
<?php if ($botInfo) : ?>
<footer class="article-footer clearfix">
  <?php echo JLayoutHelper::render('joomla.content.info_block.block', array('item' => $this->item, 'params' => $params, 'position' => 'below')); ?>
</footer>
<?php endif; ?>
<!-- //footer -->

Blog intro items

plugins\system\t3\base-bs3\html\com_content\category\blog.php

Replace

<div class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>">
	<?php
	$this->item = &$item;
	echo $this->loadTemplate('item');
?>
</div><!-- end item -->

with:

<div class="item column-<?php echo $rowcount;?><?php echo $item->state == 0 ? ' system-unpublished' : null; ?>"
	itemprop="blogPost" itemscope itemtype="http://schema.org/BlogPosting">
	<?php
	$this->item = &$item;
	echo $this->loadTemplate('item');
?>
</div><!-- end item -->

Blog intro image

plugins\system\t3\base-bs3\html\com_content\category\blog_item.php

Replace

<?php if (isset($images->image_intro) and !empty($images->image_intro)) : ?>
	<?php $imgfloat = (empty($images->float_intro)) ? $params->get('float_intro') : $images->float_intro; ?>
	<div class="pull-<?php echo htmlspecialchars($imgfloat); ?> item-image article-image article-image-intro">
		<img
			<?php if ($images->image_intro_caption):
				echo 'class="caption"' . ' title="' . htmlspecialchars($images->image_intro_caption) . '"';
			endif; ?>
		 src="/<?php echo htmlspecialchars($images->image_intro); ?>"
			alt="<?php echo htmlspecialchars($images->image_intro_alt); ?>"/>
	</div>
<?php endif; ?>

with:

<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>

Archive article

html\com_content\archive\default_items.php - This file changes a lot, it's totally restructured so it's impossible to manual embed microdata for the file, please copy the file plugins\system\t3\base-bs3\html\com_content\archive\default_items.php and override the same file in templates\ja_template\html\com_content\archive\.

We know it's a complex work and require technical skills, if you can not get it done, please order a tweak, we'll fix it.

Order Tweak now