PluXml icon indicating copy to clipboard operation
PluXml copied to clipboard

Url de la page pour les meta

Open Philippe-M opened this issue 4 years ago • 0 comments

Dans plxShow, permet de trouver l'url de la page en cours pour la mettre dans le meta type og: ou twitter:

	/**
	 * Méthode qui affiche l'url de la page selon le mode
	 *
	 * @scope	global
	 * @author	Philippe M
	 **/
	public function pageUrl() {
		# Hook Plugins
		if(eval($this->plxMotor->plxPlugins->callHook('plxShowPageUrl'))) return;

		if($this->plxMotor->mode == 'home') {
			$url = '';
		} elseif($this->plxMotor->mode == 'categorie') {
			$number = intval($this->plxMotor->cible);
			$url = 'categorie'.$number.'/'.$this->plxMotor->aCats[$this->plxMotor->cible]['url'];
		} elseif($this->plxMotor->mode == 'article') {
			$number = intval($this->plxMotor->plxRecord_arts->f('numero'));
			$url = 'article'.$number.'/'.$this->plxMotor->plxRecord_arts->f('url');
		} else { # mode par défaut
			$url = '';
		}

		return $url;
	}

Dans le header.php du thème :

<head>
[...]
<meta property="og:url" content="<?php $plxShow->urlRewrite($plxShow->pageUrl()) ?>" />
<meta name="twitter:url" content="<?php $plxShow->urlRewrite($plxShow->pageUrl()) ?>" />
[...]
</head>

Je n'utilise pas les autres mode d'affichage (archives, tags...) du coups je ne sais pas trop comment les faire.

Philippe-M avatar Aug 31 '20 13:08 Philippe-M