schema.org Category view: 5 errors for each item/article (only 1 in item view)

More
5 years 1 month ago - 5 years 1 month ago #77354 by flodariege
OK, so I modified:
category_items.php
category_items_html5.php

(I know, I should have create overrides, but I'm not confident with this procedure... So I just will have to make the correction again next time I update Flexicontent).

I have commented those lines :

51 :
Code:
$microdata_itemtype_cat = $this->params->get( 'microdata_itemtype_cat', 'Article' );
259 + 260 and 609+610 :
Code:
$microdata_itemtype = $item->params->get( 'microdata_itemtype') ? $item->params->get( 'microdata_itemtype') : $microdata_itemtype_cat; $microdata_itemtype_code = 'itemscope itemtype="http://schema.org/'.$microdata_itemtype.'"';

I also found "microdata" in lines 268 + 618 :
Code:
<li id="fc_bloglist_item_<?php echo $i; ?>" class="<?php echo $fc_item_classes; ?>" <?php echo $microdata_itemtype_code; ?> style="overflow: hidden;">
so I have simply deleted the part about microdata:
Code:
<?php echo $microdata_itemtype_code; ?>
which leaves this code:
Code:
<li id="fc_bloglist_item_<?php echo $i; ?>" class="<?php echo $fc_item_classes; ?>" style="overflow: hidden;">

Ah ! And I also deleted the "itemprop" section of the code in lines :
category_items: lignes 320+ 483 + 664 + 827
dans category_items_html5 : lignes 328 + 499 + 701 + 872
itemprop="name"
itemprop="url"

So, at this point, the Google Structured Data test is now OK.

There is no more Article microdata in my category view, so everything is fine, as you can see:


Obviously, I hope this will be fixed in the next update, so I won't have to correct it again ;-)

Dare to dream, believe the unbelievable, never take no for an answer
Attachments:
Last edit: 5 years 1 month ago by flodariege.

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #77355 by ggppdk
Hello

thanks for the suggested changes i will review your response
and will see to add new option to disable microdata inside HTML code


but also do this,
go to Flexicontent templates management and make a copy of 'blog' template as blog_custom1
this way you will have a backup of your current changes,


and you can either use this new template in categories or just keep for backup,
the downside of copies is that they will not get updates from us, but the benefit is that you can full customize without worries of it being overwritten

PS there is a new official release, (auto update link will point soon to it)
here is the new release together with a complete list of changes and fixes

v3.3.16
github.com/FLEXIcontent/flexicontent-cck/releases

Hopefully this will be last of v3.3.1.x release

And move to Flexicontent v4 for J4 ?


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #77356 by flodariege
Thanks for your attention.

By the way, I always keep a copy of the files I modify (with one subfolder "before changes" and one subfolder "after changes"), and as I don't have such a good memory, I keep track of everything I do in a Trello board.

So in this case, if updating Flexicontent delete my changes, I just have to make the changes again in those php files (since i'm not 100% sure the whole file is strictly the same than the one in the previous version).

I will sure update Flexicontent, as soon as it appears in the admin.

Thank you!

Dare to dream, believe the unbelievable, never take no for an answer

Please Log in or Create an account to join the conversation.

More
5 years 1 month ago #77372 by ggppdk
Hello

i will talk with Emmanuel about best approach to this


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star...

Please Log in or Create an account to join the conversation.

More
5 years 3 weeks ago - 5 years 3 weeks ago #77645 by iamrobert
I do it via json in item.php and avoid itemscope:
Code:
<?php /* + STRUCTURED DATA GOOGLE ======================================================================*/ $structured_data = ''; ?> <?php if ($show_schema == 1) : ?> <?php if (($microdata_itemtype == 'Article')||($microdata_itemtype == 'NewsArticle')||($microdata_itemtype == 'BlogPosting')): ?> <?php if ( $json_description != '' || $imageURL != '' ) { $structured_data .= '<script type="application/ld+json"> { "@context": "http://schema.org", "@type": "' . $microdata_itemtype . '", "mainEntityOfPage": { "@type": "WebPage", "@id": "' . JURI::current() . '" }, "headline": ' . json_encode( $item->title, JSON_UNESCAPED_UNICODE ) . ', ' . $JSONimageURL . ' ' . $datePublished . ' ' . $dateModified . ' "author": { "@type": "Person", "name": ' . json_encode( $author, JSON_UNESCAPED_UNICODE ) . ' }, "publisher": { "@type": "Organization", "name": ' . json_encode( $company_brand_name, JSON_UNESCAPED_UNICODE ) . ', "logo": { "@type": "ImageObject", "url": "' . $company_logo_image_name . '" } }, "description": ' . json_encode( $json_description, JSON_UNESCAPED_UNICODE ) . ' } </script>'; } ?> <?php endif; ?> <?php endif; ?>

To call the values I have a lobal-logic.php file called in item.php:
require_once( JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates' . DS . 'iamrobert' . DS . 'common-code' . DS . 'global-logic.php' );


global-logic.php
Code:
<?php defined( '_JEXEC' )or die( 'Restricted access' ); /* + OPEN GRAPH META TAGSSOCIAL SHARES https://blog.kissmetrics.com/open-graph-meta-tags/ https://moz.com/blog/meta-data-templates-123 ----------------------------------------------------------------------- REMEMBER TO SET IMAGE FIELD NUMBER line 81 ====================================================================== */ $document = JFactory::getDocument(); $app = JFactory::getApplication(); //TEMPLATE PATH $tpath = JURI::base(true).'/templates/'.$app->getTemplate().'/'; //$app = JFactory::getApplication('site'); $template = $app->getTemplate(true); /* + COMPANY NAME + LOGO = Set in Joomla Site Template ======================================================================*/ // $company_brand_name = $template->params->get('company_brand_name'); $company_logo_image_name = JURI::base() . $template->params->get('company_logo_image_name'); if (isset($company_brand_name )) { if ($company_brand_name != 'NAME') { $company_brand_name = $template->params->get('company_brand_name'); } else if ($company_brand_name == 'NAME') { $company_brand_name = JFactory::getConfig()->get( 'sitename' ); } } //SITENAME $document->setMetaData( 'og:site_name', "$company_brand_name", 'property' ); //AUTHOR $author = $this->item->author; $datePublished = ""; //PUBLISHED DATE if(!empty ($this->item->created)) { $datePublished = date('Y-m-d',strtotime($this->item->created)); $datePublished = '"datePublished: "'.$datePublished.'",'; } $dateModified = ""; //MODIFIED DATE if(!empty ($this->item->modified)) { $dateModified = date('Y-m-d',strtotime($this->item->modified)); $dateModified = '"dateModified: "'.$dateModified.'",'; } //SITE URL: $siteURL = 'http' . ( empty( $_SERVER[ 'HTTPS' ] ) ? '' : 's' ) . '://' . $_SERVER[ 'SERVER_NAME' ]; // GET OPENGRAPH TYPE: //https://developers.facebook.com/docs/reference/opengraph/ $fb_og_type = $this->params->get( 'fb_og_type' ); //GET TITLE $page_title = $document->getTitle(); //GET CURRENT PAGE URL; $current_page_url = JURI::current(); //$document->setMetaData( 'og:site_name', "$company_name", 'property' ); //SET URL $document->setMetaData( 'og:url', "$current_page_url", 'property' ); $document->setMetaData( 'og:type', "$fb_og_type", 'property' ); $document->setMetaData( 'twitter:card', "summary_large_image" ); //SET TITLE $document->setMetaData( 'og:title', "$page_title", 'property' ); $document->setMetaData( 'twitter:title', "$page_title" ); /* + SET DESCRIPTION ======================================================================*/ //SET INTROTEXT LENGTH $intro_text_cut_text = $this->params->get( 'intro_text_cut_text', '160' ); $intro_text = JHtmlString::truncate( $item->introtext, $intro_text_cut_text, true, false ); $intro_text = str_replace( '...', '', $intro_text ); //GET META DESCRIPTION: $meta_description = $document->getMetaData( "description" ); $json_description = ''; if (!empty($_mp=$menu->params->get('menu-meta_description'))) { //+ GET MENU META DESCRIPTION $document->setDescription( $_mp ); $document->setMetaData( 'twitter:description', "$_mp" ); $document->setMetaData( 'og:description', "$_mp", 'property' ); $document->setMetaData( 'description', "$_mp", 'itemprop' ); // $json_description = $_mp; } elseif ( !empty( $item->metadesc ) ) { //+ GET ITEM META DESCRIPTION $meta_item = htmlspecialchars_decode($item->metadesc); $document->setDescription( $meta_item ); $document->setMetaData( 'twitter:description', "$meta_item" ); $document->setMetaData( 'og:description', "$meta_item", 'property' ); $document->setMetaData( 'description', "$meta_item", 'itemprop' ); $json_description = $meta_item; } elseif ( !empty( $intro_text ) ) { //+ GET INTRO TEXT META DESCRIPTION $document->setDescription("$intro_text"); $document->setMetaData( 'twitter:description', "$intro_text" ); $document->setMetaData( 'og:description', "$intro_text", 'property' ); $document->setMetaData( 'description', "$intro_text", 'itemprop' ); $json_description = $intro_text; } elseif ( !empty( $meta_description ) ) { //+ GET SIDE META DESCRIPTION $document->setDescription("$meta_description"); $document->setMetaData( 'twitter:description', "$meta_description" ); $document->setMetaData( 'og:description', "$meta_description", 'property' ); $document->setMetaData( 'description', "$meta_description", 'itemprop' ); $json_description = $meta_description; } /* + SET IMAGE FIELD NUMBER ======================================================================*/ $imagefield = 40; $imageURL = ''; $JSONimageURL = ''; if ( isset( $item->fieldvalues[ $imagefield ] ) ) { if(isset($this->item->fieldvalues[$this->item->fields['image']->id])) { $imageURL = $siteURL . $item->fields[ 'image' ]->{"display_large_src"}; $document->setMetaData( 'twitter:image', "$imageURL" ); $document->setMetaData( 'og:image', "$imageURL", 'property'); $JSONimageURL = '"image": ["'.$imageURL.'"],'; } } ?>
Last edit: 5 years 3 weeks ago by iamrobert.

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 1.067 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline