Advertisement:

Author Topic: [TuTo]Microdata - Breadcrumbs - SMF  (Read 3870 times)

Offline Dhayzon

  • Sophist Member
  • *****
  • Posts: 1,162
  • Gender: Male
  • DhayZone RevolutioN
    • Dhayzon on GitHub
    • @dhayzon on Twitter
    • http://dhayzon.com/
[TuTo]Microdata - Breadcrumbs - SMF
« on: July 19, 2016, 03:46:41 PM »
dentro de la funcion
Code: [Select]
function theme_linktree($force_show = false)

esta  nuestro  Breadcrumb De SMF, exactamente  en el archivo Index.template.php de nuestro tema.

no te tengo que explicar que es esto o para que sirve, Esta información es redundante y existen muchos artículos en Internet que te explican detalladamente que significa microdata y cual es su función.
pero te dejo el link para que te informes, Esto para que sepas que estamos haciendo
https://developers.google.com/search/docs/data-types/breadcrumbs

Buscaremos  y reemplazaremos esto
Code: [Select]
// Show a linktree. This is that thing that shows "My Community | General Category | General Discussion"..
function theme_linktree($force_show = false)
{
global $context, $settings, $options, $shown_linktree;

// If linktree is empty, just return - also allow an override.
if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
return;

echo '
<div class="navigate_section">
<ul>';

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
echo '
<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';

// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '
<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>' : '<span>' . $tree['name'] . '</span>';

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo ' &#187;';

echo '
</li>';
}
echo '
</ul>
</div>';

$shown_linktree = true;
}

por este otro

Code: [Select]
function theme_linktree($force_show = false)
{
global $context, $settings, $options, $shown_linktree;

// If linktree is empty, just return - also allow an override.
if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
return;

echo '
<div class="navigate_section">
<ol itemscope itemtype="http://schema.org/BreadcrumbList">';
    $pItemprop = 1;
// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
echo '
<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '  itemprop="itemListElement" itemscope
 itemtype="http://schema.org/ListItem">';

// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'];

// Show the link, including a URL if it should have one.
echo $settings['linktree_link'] && isset($tree['url']) ? '
<a itemprop="item" href="' . $tree['url'] . '"><span  itemprop="name">' . $tree['name'] . '</span></a>' : '<span  itemprop="name">' . $tree['name'] . '</span>';

// Show something after the link...?
if (isset($tree['extra_after']))
echo $tree['extra_after'];

// Don't show a separator for the last one.
if ($link_num != count($context['linktree']) - 1)
echo ' <span> &#187;</span>';
 
echo '<meta itemprop="position" content="'.$pItemprop++.'" />
</li>';
}
echo '
</ol>
</div>';

$shown_linktree = true;
}

el resultado y  para que lo hacemos, ya puedes leerlo y analizarlo detenidamente en el link que te deje arriba.

esta validado en https://search.google.com/structured-data/testing-tool

Offline Rock Lee

  • Local Moderator
  • SMF Hero
  • *
  • Posts: 2,793
  • Gender: Male
  • I also speak english :D
    • BomberCode.Oficial on Facebook
    • RockLee-BC on GitHub
    • @Bomber_Code on Twitter
    • Bomber Code ~ La nueva era del conocimiento
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #1 on: July 19, 2016, 07:20:25 PM »
Parece interesante algo había leído pero no había tenido tiempo :P de entenderlo del todo... ya lo mirare y probare en un smf de pruebas tengo!


Saludos!
¡Regresando como cual Fenix! ~ Bomber Code © 2018
Ayudas - Aportes - Tutoriales - Y mucho mas!!!


Ayudame via PayPal

Offline ^SoporteGSM^

  • Jr. Member
  • **
  • Posts: 178
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #2 on: July 19, 2016, 07:53:21 PM »
Basicamente para que sirve este microdata???

Offline vicram10

  • SMF Hero
  • ******
  • Posts: 5,900
  • Gender: Male
  • Founding Father of Ultimate Portal
    • vmrm10 on Facebook
    • @vicram_10 on Twitter
    • Noticias Tecnologicas, Tutoriales e Internet
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #3 on: July 20, 2016, 09:39:00 PM »
interesante, gracias dhayzon

Offline jclconsultor

  • Newbie
  • *
  • Posts: 2
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #4 on: January 06, 2017, 11:11:29 AM »
Buenas tardes Dhayzon, gracias por tu idea, la tome y la efectúe de otra versión como schema, para evitar un efecto que me causa en mi tema bellacita del Forotailandia, anexo como la realice, saludos.

NOTA: A igual que la versión realizada por ti, solo tienes que copiar la función y listo, pruebas con la herramienta de google y indexa, saludos.


function theme_linktree($force_show = false) {
   global $context, $settings, $options, $shown_linktree;
   $Ae_index = 0;
   $i=0;$listitem=null;
   
   if(!empty($_REQUEST['action']) || !empty($_REQUEST['topic']) || !empty($_REQUEST['board']) || !empty($_REQUEST['page']) || !empty($_REQUEST['blog']))
      $Ae_index = 1;

   if(empty($Ae_index))
      return;

   // If linktree is empty, just return - also allow an override.
   if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
      return;

   echo '
   <div class="navigate_section">
      <ul>';

   // Each tree item has a URL and name. Some may have extra_before and extra_after.
   foreach ($context['linktree'] as $link_num => $tree) {
      $i++;
      echo '
         <li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';

      // Show something before the link?
      if (isset($tree['extra_before']))
         echo $tree['extra_before'];
      
      // Show the link, including a URL if it should have one.
      echo $settings['linktree_link'] && isset($tree['url']) ? '
            <a href="'.$tree['url'].'"><span>'.$tree['name'].'</span></a>' : '<span>'.$tree['name'].'</span>';
                  
      // Show something after the link...?
      if (isset($tree['extra_after']))
         echo $tree['extra_after'];

      // Don't show a separator for the last one.
      if ($link_num != count($context['linktree']) - 1)
         echo ' &#187;';
      
      echo '
         </li>';
      
      //JCL SCHEMA BreadcrumbList index.template - fun theme_linktree
      if ($listitem!=null){$listitem .=',';}
      $listitem .= '
         {"@type": "ListItem",
         "position": '.$i.',
         "item": {
           "@id": "'.$tree['url'].'",
           "name": "'.$tree['name'].'"}
         }';
      //--
   }
   echo '
      </ul>
   </div>';
   
   //BreadcrumbList
   echo '
   
      <!-- JCL SCHEMA BreadcrumbList index.template - fun theme_linktree -->
      
      <script type="application/ld+json">
      {
        "@context": "schema.org",
        "@type": "BreadcrumbList",
        "itemListElement":
        ['.$listitem.']
      }
      </script>
      
      <!-- /JCL SCHEMA BreadcrumbList index.template - fun theme_linktree -->
      
   ';
   //--
   $shown_linktree = true;
}

Offline jclconsultor

  • Newbie
  • *
  • Posts: 2
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #5 on: January 06, 2017, 03:22:26 PM »
Disculpen todos, pero seguí validando ya que en mi tema bellacita se repite 2 veces el esquema y agregue unos cambios con variables globales que impide que se repita el schema en el tema, quedando perfecto:

Nota: por razones de limitacion por politicas de span en el foro, en donde indica la url: schema.org hay que colocar h t t p: / / schema.org, en forma correcta.

function theme_linktree($force_show = false) {
   global $context, $settings, $options, $shown_linktree;
   $Ae_index = 0;
   
   //JCL SCHEMA BreadcrumbList index.template - fun theme_linktree
   global $jcl_schema;
   global $jcl_schemaold;
   $i=0;$listitem=null;
   //--
   
   if(!empty($_REQUEST['action']) || !empty($_REQUEST['topic']) || !empty($_REQUEST['board']) || !empty($_REQUEST['page']) || !empty($_REQUEST['blog']))
      $Ae_index = 1;

   if(empty($Ae_index))
      return;

   // If linktree is empty, just return - also allow an override.
   if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
      return;

   echo '
   <div class="navigate_section">
      <ul>';

   // Each tree item has a URL and name. Some may have extra_before and extra_after.
   foreach ($context['linktree'] as $link_num => $tree) {
      $i++;
      echo '
         <li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';

      // Show something before the link?
      if (isset($tree['extra_before']))
         echo $tree['extra_before'];
      
      // Show the link, including a URL if it should have one.
      echo $settings['linktree_link'] && isset($tree['url']) ? '
            <a href="'.$tree['url'].'"><span>'.$tree['name'].'</span></a>' : '<span>'.$tree['name'].'</span>';
                  
      // Show something after the link...?
      if (isset($tree['extra_after']))
         echo $tree['extra_after'];

      // Don't show a separator for the last one.
      if ($link_num != count($context['linktree']) - 1)
         echo ' &#187;';
      
      echo '
         </li>';
      
      //JCL SCHEMA BreadcrumbList index.template - fun theme_linktree
      if ($listitem!=null){$listitem .=',';}
      $listitem .= '
         {"@type": "ListItem",
         "position": '.$i.',
         "item": {
           "@id": "'.$tree['url'].'",
           "name": "'.$tree['name'].'"}
         }';
      //--
   }
   echo '
      </ul>
   </div>';
   
   //BreadcrumbList
   $jcl_schema = '
   
      <!-- JCL SCHEMA BreadcrumbList index.template - fun theme_linktree -->
      
      <script type="application/ld+json">
      {
        "@context": "hxxp:schema.org [nonactive]",
        "@type": "BreadcrumbList",
        "itemListElement":
        ['.$listitem.']
      }
      </script>
      
      <!-- /JCL SCHEMA BreadcrumbList index.template - fun theme_linktree -->
      
      ';
   if (($jcl_schema!=$jcl_schemaold) || ($jcl_schema==null)) {
      echo $jcl_schema;
      $jcl_schemaold=$jcl_schema;
   }
   //--
   $shown_linktree = true;
}

Offline ^SoporteGSM^

  • Jr. Member
  • **
  • Posts: 178
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #6 on: March 22, 2019, 09:40:54 PM »
Como seria el ajuste en 2.1 RC1???

Offline Diego Andrés

  • Customizer
  • SMF Hero
  • *
  • Posts: 3,196
  • Gender: Male
  • We know, we'll be coming
    • MeTiroAtuTia on GitHub
    • @bihgetter on Twitter
    • SMF Tricks - Free & Premium Themes
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #7 on: March 22, 2019, 10:44:01 PM »
Es un poco diferente, pero debería de ser adaptable sin mucho esfuerzo.

SMF Tricks - Free & Premium Responsive Themes for SMF.

Offline ^SoporteGSM^

  • Jr. Member
  • **
  • Posts: 178
Re: [TuTo]Microdata - Breadcrumbs - SMF
« Reply #8 on: March 22, 2019, 11:01:54 PM »
Como seria la adaptacion?

Code: [Select]
function theme_linktree($force_show = false)
{
global $context, $shown_linktree, $scripturl, $txt;

// If linktree is empty, just return - also allow an override.
if (empty($context['linktree']) || (!empty($context['dont_default_linktree']) && !$force_show))
return;
echo '
<div class="navigate_section">
<ul>';

if ($context['user']['is_logged'])
echo '
<li class="unread_links">
<a href="', $scripturl, '?action=unread" title="', $txt['unread_since_visit'], '">', $txt['view_unread_category'], '</a>
<a href="', $scripturl, '?action=unreadreplies" title="', $txt['show_unread_replies'], '">', $txt['unread_replies'], '</a>
</li>';

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
echo '
<li', ($link_num == count($context['linktree']) - 1) ? ' class="last"' : '', '>';

// Don't show a separator for the first one.
// Better here. Always points to the next level when the linktree breaks to a second line.
// Picked a better looking HTML entity, and added support for RTL plus a span for styling.
if ($link_num != 0)
echo '
<span class="dividers">', $context['right_to_left'] ? ' &#9668; ' : ' &#9658; ', '</span>';

// Show something before the link?
if (isset($tree['extra_before']))
echo $tree['extra_before'], ' ';

// Show the link, including a URL if it should have one.
if (isset($tree['url']))
echo '
<a href="' . $tree['url'] . '"><span>' . $tree['name'] . '</span></a>';
else
echo '
<span>' . $tree['name'] . '</span>';

// Show something after the link...?
if (isset($tree['extra_after']))
echo ' ', $tree['extra_after'];

echo '
</li>';
}

echo '
</ul>
</div><!-- .navigate_section -->';

$shown_linktree = true;
}