Created
July 15, 2019 14:41
-
-
Save Septdir/9d59e0d4ea97d4ab5427f762866e5b2b to your computer and use it in GitHub Desktop.
com_content artcle for yootheme pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Septdir Workshop Package | |
* @version __DEPLOY_VERSION__ | |
* @author Septdir Workshop - septdir.com | |
* @copyright Copyright (c) 2018 - 2019 Septdir Workshop. All rights reserved. | |
* @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html | |
* @link https://www.septdir.com/ | |
*/ | |
defined('_JEXEC') or die; | |
use Joomla\CMS\Factory; | |
use Joomla\CMS\Router\Route; | |
use Joomla\CMS\Uri\Uri; | |
use Joomla\Registry\Registry; | |
// Canonical & meta | |
$app = Factory::getApplication(); | |
$doc = Factory::getDocument(); | |
$slug = $this->item->id . ':' . $this->item->alias; | |
$catid = $app->input->get('catid'); | |
$link = ContentHelperRoute::getArticleRoute($slug, $catid); | |
// Prepare canonical | |
$uri = Uri::getInstance(); | |
$canonical = Uri::getInstance(Route::_($link)); | |
// Set canonical | |
$root = $uri->toString(array('scheme', 'host', 'port')); | |
$canonical = $canonical->toString(); | |
$doc->addCustomTag('<link href="' . $root . $canonical . '" rel="canonical"/>'); | |
// Redirect | |
$redirect = Uri::getInstance(Route::_($link)); | |
$current = $uri->toString(array('path', 'query', 'fragment')); | |
$redirect = $redirect->toString(array('path', 'query', 'fragment')); | |
if (urldecode($current) != urldecode($redirect)) | |
{ | |
Factory::getApplication()->redirect($redirect, 301); | |
} | |
// Set title | |
$metaTitle = $doc->getTitle(); | |
$doc->setTitle($metaTitle); | |
// Set meta image | |
$metaImages = new Registry($this->item->images); | |
if ($metaImage = $metaImages->get('image_intro', 'images/meta.png')) | |
{ | |
$doc->setMetadata('image', $root . '/' . $metaImage); | |
} | |
// Prepare meta | |
$url = $root . $canonical; | |
$sitename = $app->get('sitename'); | |
// Set meta twitter | |
$doc->setMetaData('twitter:card', 'summary_large_image'); | |
$doc->setMetaData('twitter:site', $sitename); | |
$doc->setMetaData('twitter:creator', $sitename); | |
$doc->setMetaData('twitter:title', $metaTitle); | |
$doc->setMetaData('twitter:url', $url); | |
if ($metaDescription = $doc->getMetaData('description')) | |
{ | |
$doc->setMetaData('twitter:description', $metaDescription); | |
} | |
if ($metaImage = $doc->getMetaData('image')) | |
{ | |
$doc->setMetaData('twitter:image', $metaImage); | |
} | |
// Set meta open graph | |
$doc->setMetadata('og:type', 'website', 'property'); | |
$doc->setMetaData('og:site_name', $sitename, 'property'); | |
$doc->setMetaData('og:title', $metaTitle, 'property'); | |
$doc->setMetaData('og:url', $url, 'property'); | |
if ($metaDescription) | |
{ | |
$doc->setMetaData('og:description', $metaDescription, 'property'); | |
} | |
if ($metaImage) | |
{ | |
$doc->setMetaData('og:image', $metaImage, 'property'); | |
} | |
// Include yootheme | |
include_once(JPATH_THEMES . '/yootheme/html/com_content/article/default.php'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @package Atom-S Start site package | |
* @version __DEPLOY_VERSION__ | |
* @author Septdir Workshop - septdir.com | |
* @copyright Copyright (c) 2018 - 2019 Septdir Workshop. All rights reserved. | |
* @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html | |
* @link https://www.septdir.com/ | |
*/ | |
defined('_JEXEC') or die; | |
include_once(JPATH_THEMES . '/yootheme/html/com_content/article/default_links.php'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment