Fix getStructuredData for organization
This commit is contained in:
parent
6be60efaba
commit
8a6ae84fb0
@ -540,7 +540,7 @@ function includeContainer($containerref)
|
|||||||
*/
|
*/
|
||||||
function getStructuredData($type, $data = array())
|
function getStructuredData($type, $data = array())
|
||||||
{
|
{
|
||||||
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
|
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs, $pagelangs; // Very important. Required to have var available when running inluded containers.
|
||||||
|
|
||||||
if ($type == 'software')
|
if ($type == 'software')
|
||||||
{
|
{
|
||||||
@ -565,6 +565,41 @@ function getStructuredData($type, $data = array())
|
|||||||
}'."\n";
|
}'."\n";
|
||||||
$ret .= '</script>'."\n";
|
$ret .= '</script>'."\n";
|
||||||
}
|
}
|
||||||
|
elseif ($type == 'organization')
|
||||||
|
{
|
||||||
|
$companyname = $mysoc->name;
|
||||||
|
$url = $mysoc->url;
|
||||||
|
|
||||||
|
$ret = '<!-- Add structured data for blog post -->'."\n";
|
||||||
|
$ret .= '<script type="application/ld+json">'."\n";
|
||||||
|
$ret .= '{
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "'.dol_escape_json($companyname).'",
|
||||||
|
"url": "'.$url.'",
|
||||||
|
"logo": "/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo).'",
|
||||||
|
"contactPoint": {
|
||||||
|
"@type": "ContactPoint",
|
||||||
|
"contactType": "Contact",
|
||||||
|
"email": "'.dol_escape_json($mysoc->email).'"
|
||||||
|
},';
|
||||||
|
if (is_array($mysoc->socialnetworks) && count($mysoc->socialnetworks) > 0) {
|
||||||
|
$ret .= '"sameAs": [';
|
||||||
|
$i = 0;
|
||||||
|
foreach($mysoc->socialnetworks as $key => $value) {
|
||||||
|
if ($key == 'linkedin') {
|
||||||
|
$ret.= '"https://www.'.$key.'.com/company/'.dol_escape_json($value).'"';
|
||||||
|
} else {
|
||||||
|
$ret.= '"https://www.'.$key.'.com/'.dol_escape_json($value).'"';
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
if ($i < count($mysoc->socialnetworks)) $ret .= ', ';
|
||||||
|
}
|
||||||
|
$ret .= '],'."\n";
|
||||||
|
}
|
||||||
|
$ret .= "\n".'}'."\n";
|
||||||
|
$ret .= '</script>'."\n";
|
||||||
|
}
|
||||||
elseif ($type == 'blogpost')
|
elseif ($type == 'blogpost')
|
||||||
{
|
{
|
||||||
if (!empty($websitepage->author_alias))
|
if (!empty($websitepage->author_alias))
|
||||||
@ -581,7 +616,7 @@ function getStructuredData($type, $data = array())
|
|||||||
|
|
||||||
$pageurl = str_replace('__WEBSITE_KEY__', $website->ref, $pageurl);
|
$pageurl = str_replace('__WEBSITE_KEY__', $website->ref, $pageurl);
|
||||||
$title = str_replace('__WEBSITE_KEY__', $website->ref, $title);
|
$title = str_replace('__WEBSITE_KEY__', $website->ref, $title);
|
||||||
$image = str_replace('__WEBSITE_KEY__', $website->ref, $image);
|
$image = 'medias/'.str_replace('__WEBSITE_KEY__', $website->ref, $image);
|
||||||
$companyname = str_replace('__WEBSITE_KEY__', $website->ref, $companyname);
|
$companyname = str_replace('__WEBSITE_KEY__', $website->ref, $companyname);
|
||||||
$description = str_replace('__WEBSITE_KEY__', $website->ref, $description);
|
$description = str_replace('__WEBSITE_KEY__', $website->ref, $description);
|
||||||
|
|
||||||
@ -598,6 +633,7 @@ function getStructuredData($type, $data = array())
|
|||||||
"image": [
|
"image": [
|
||||||
"'.dol_escape_json($image).'"
|
"'.dol_escape_json($image).'"
|
||||||
],
|
],
|
||||||
|
"dateCreated": "'.dol_print_date($websitepage->date_creation, 'dayhourrfc').'",
|
||||||
"datePublished": "'.dol_print_date($websitepage->date_creation, 'dayhourrfc').'",
|
"datePublished": "'.dol_print_date($websitepage->date_creation, 'dayhourrfc').'",
|
||||||
"dateModified": "'.dol_print_date($websitepage->date_modification, 'dayhourrfc').'",
|
"dateModified": "'.dol_print_date($websitepage->date_modification, 'dayhourrfc').'",
|
||||||
"author": {
|
"author": {
|
||||||
@ -611,9 +647,20 @@ function getStructuredData($type, $data = array())
|
|||||||
"@type": "ImageObject",
|
"@type": "ImageObject",
|
||||||
"url": "/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo).'"
|
"url": "/wrapper.php?modulepart=mycompany&file=logos%2F'.urlencode($mysoc->logo).'"
|
||||||
}
|
}
|
||||||
},
|
},'."\n";
|
||||||
"description": "'.dol_escape_json($description).'"
|
if ($websitepage->keywords) {
|
||||||
}'."\n";
|
$ret .= '"keywords": [';
|
||||||
|
$i = 0;
|
||||||
|
$arrayofkeywords = explode(',', $websitepage->keywords);
|
||||||
|
foreach($arrayofkeywords as $keyword) {
|
||||||
|
$ret.= '"'.dol_escape_json($keyword).'"';
|
||||||
|
$i++;
|
||||||
|
if ($i < count($arrayofkeywords)) $ret .= ', ';
|
||||||
|
}
|
||||||
|
$ret .= '],'."\n";
|
||||||
|
}
|
||||||
|
$ret .= '"description": "'.dol_escape_json($description).'"';
|
||||||
|
$ret .= "\n".'}'."\n";
|
||||||
$ret .= '</script>'."\n";
|
$ret .= '</script>'."\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3745,6 +3745,13 @@ class Societe extends CommonObject
|
|||||||
$this->instagram_url = empty($conf->global->MAIN_INFO_SOCIETE_INSTAGRAM_URL) ? '' : $conf->global->MAIN_INFO_SOCIETE_INSTAGRAM_URL;
|
$this->instagram_url = empty($conf->global->MAIN_INFO_SOCIETE_INSTAGRAM_URL) ? '' : $conf->global->MAIN_INFO_SOCIETE_INSTAGRAM_URL;
|
||||||
$this->youtube_url = empty($conf->global->MAIN_INFO_SOCIETE_YOUTUBE_URL) ? '' : $conf->global->MAIN_INFO_SOCIETE_YOUTUBE_URL;
|
$this->youtube_url = empty($conf->global->MAIN_INFO_SOCIETE_YOUTUBE_URL) ? '' : $conf->global->MAIN_INFO_SOCIETE_YOUTUBE_URL;
|
||||||
$this->github_url = empty($conf->global->MAIN_INFO_SOCIETE_GITHUB_URL) ? '' : $conf->global->MAIN_INFO_SOCIETE_GITHUB_URL;
|
$this->github_url = empty($conf->global->MAIN_INFO_SOCIETE_GITHUB_URL) ? '' : $conf->global->MAIN_INFO_SOCIETE_GITHUB_URL;
|
||||||
|
$this->socialnetworks = array();
|
||||||
|
if (! empty($this->facebook_url)) $this->socialnetworks['facebook'] = $this->facebook_url;
|
||||||
|
if (! empty($this->twitter_url)) $this->socialnetworks['twitter'] = $this->twitter_url;
|
||||||
|
if (! empty($this->linkedin_url)) $this->socialnetworks['linkedin'] = $this->linkedin_url;
|
||||||
|
if (! empty($this->instagram_url)) $this->socialnetworks['instagram'] = $this->instagram_url;
|
||||||
|
if (! empty($this->youtube_url)) $this->socialnetworks['youtube'] = $this->youtube_url;
|
||||||
|
if (! empty($this->github_url)) $this->socialnetworks['github'] = $this->github_url;
|
||||||
|
|
||||||
// Id prof generiques
|
// Id prof generiques
|
||||||
$this->idprof1 = empty($conf->global->MAIN_INFO_SIREN) ? '' : $conf->global->MAIN_INFO_SIREN;
|
$this->idprof1 = empty($conf->global->MAIN_INFO_SIREN) ? '' : $conf->global->MAIN_INFO_SIREN;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user