1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

Experimental schema template added to FAQs.

This commit is contained in:
Cameron
2022-02-04 13:26:52 -08:00
parent c17b985441
commit 2097778cc5
3 changed files with 27 additions and 2 deletions

View File

@@ -837,6 +837,7 @@ class e_parse
$parse = e107::getScParser();
$parse->setMode('schema');
$text = e107::getScParser()->parseCodes($text, $parseSCFiles, $extraCodes, $eVars);
$text = str_replace('<!-- >', '', $text); // cleanup
$parse->setMode('default');
return $text;

View File

@@ -419,7 +419,7 @@ class faq
$FAQ_LISTALL['end'] = str_replace($tsrch,$trepl, $FAQ_LISTALL['end']);
}
$schemaItems = [];
foreach ($data as $rw)
{
$rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']),'dashl');
@@ -428,7 +428,7 @@ class faq
if(!empty($schemaTemplate['item']))
{
$schema .= $tp->parseSchemaTemplate($schemaTemplate['item'],false,$sc);
$schemaItems[] = $tp->parseSchemaTemplate($schemaTemplate['item'],false,$sc);
}
if($sc->item == $rw['faq_id'])
@@ -452,6 +452,12 @@ class faq
$prevcat = $rw['faq_info_order'];
$sc->counter++;
}
if(!empty($schemaItems))
{
$schema .= implode(",", $schemaItems);
}
$text .= ($start) ? $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc) : "";
if(!empty($schemaTemplate['end']))

View File

@@ -34,3 +34,21 @@ $FAQS_TEMPLATE['all']['end'] = "
$FAQS_TEMPLATE['caption'] = "{FAQ_CAPTION} <small>{FAQ_COUNT}</small>";
/** @experimental */
$FAQS_TEMPLATE['schema']['start'] = '{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [';
$FAQS_TEMPLATE['schema']['item'] = '{
"@type": "Question",
"name": "{FAQ_QUESTION}",
"acceptedAnswer": {
"@type": "Answer",
"text": "{FAQ_ANSWER}"
}
}';
$FAQS_TEMPLATE['schema']['end'] = ']
}
';