tutorial [JSON-LD] BreadcrumbList datos estructurados para smf 2.1

Started by Dhayzon, September 02, 2020, 05:40:57 PM

Previous topic - Next topic

Dhayzon

archivo a editar

index.template.php

agregar al final antes de ?>


function schema_linktree(){
global $context, $shown_linktree;

// If linktree is empty, just return - also allow an override.
if (empty($context['linktree']))
return;
 
$schema =  array(
'@context'  => 'http://schema.org',
'@type'  => 'BreadcrumbList',
);

// Each tree item has a URL and name. Some may have extra_before and extra_after.
foreach ($context['linktree'] as $link_num => $tree)
{
$schema['itemListElement'][] = array(
'@type'  => 'ListItem',
'position'  => $link_num+1,
'item'  => array(
'@id'  => $tree['url'],
'name'  => $tree['name'],
),
);
}
   
echo'
<script type="application/ld+json">
'.json_encode($schema, JSON_PRETTY_PRINT).'
</script>
';

 
}





justo antes de </body>

agregar

'.schema_linktree().'



resultado




pueden hacer su test en https://search.google.com/structured-data/testing-tool

-Rock Lee-

Oh parece interesante y no requiere mucho, buena :P de paso lo movi a tutoriales!


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

vicram10

Excelente, si lo mismo hicimos pero no del linktree sino de los post en si, en nuestra web que tenemos con Frony y lo estamos volviendo a levantar de a poco.

El mod que creamos fue justamente tener forma de mostrar como schema los post de ciertos foros y de acuerdo al tipo de schema que se quiere elegir, articulo, movie, etc.

Excelente Dhayzon

Advertisement: