mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
Experimental schema template added to FAQs.
This commit is contained in:
@@ -837,6 +837,7 @@ class e_parse
|
|||||||
$parse = e107::getScParser();
|
$parse = e107::getScParser();
|
||||||
$parse->setMode('schema');
|
$parse->setMode('schema');
|
||||||
$text = e107::getScParser()->parseCodes($text, $parseSCFiles, $extraCodes, $eVars);
|
$text = e107::getScParser()->parseCodes($text, $parseSCFiles, $extraCodes, $eVars);
|
||||||
|
$text = str_replace('<!-- >', '', $text); // cleanup
|
||||||
$parse->setMode('default');
|
$parse->setMode('default');
|
||||||
return $text;
|
return $text;
|
||||||
|
|
||||||
|
@@ -419,7 +419,7 @@ class faq
|
|||||||
$FAQ_LISTALL['end'] = str_replace($tsrch,$trepl, $FAQ_LISTALL['end']);
|
$FAQ_LISTALL['end'] = str_replace($tsrch,$trepl, $FAQ_LISTALL['end']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$schemaItems = [];
|
||||||
foreach ($data as $rw)
|
foreach ($data as $rw)
|
||||||
{
|
{
|
||||||
$rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']),'dashl');
|
$rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']),'dashl');
|
||||||
@@ -428,7 +428,7 @@ class faq
|
|||||||
|
|
||||||
if(!empty($schemaTemplate['item']))
|
if(!empty($schemaTemplate['item']))
|
||||||
{
|
{
|
||||||
$schema .= $tp->parseSchemaTemplate($schemaTemplate['item'],false,$sc);
|
$schemaItems[] = $tp->parseSchemaTemplate($schemaTemplate['item'],false,$sc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($sc->item == $rw['faq_id'])
|
if($sc->item == $rw['faq_id'])
|
||||||
@@ -452,6 +452,12 @@ class faq
|
|||||||
$prevcat = $rw['faq_info_order'];
|
$prevcat = $rw['faq_info_order'];
|
||||||
$sc->counter++;
|
$sc->counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!empty($schemaItems))
|
||||||
|
{
|
||||||
|
$schema .= implode(",", $schemaItems);
|
||||||
|
}
|
||||||
|
|
||||||
$text .= ($start) ? $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc) : "";
|
$text .= ($start) ? $tp->parseTemplate($FAQ_LISTALL['end'], true, $sc) : "";
|
||||||
|
|
||||||
if(!empty($schemaTemplate['end']))
|
if(!empty($schemaTemplate['end']))
|
||||||
|
@@ -34,3 +34,21 @@ $FAQS_TEMPLATE['all']['end'] = "
|
|||||||
$FAQS_TEMPLATE['caption'] = "{FAQ_CAPTION} <small>{FAQ_COUNT}</small>";
|
$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'] = ']
|
||||||
|
}
|
||||||
|
';
|
||||||
|
Reference in New Issue
Block a user