Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plxUtils::title2url ne prend pas en compte les ancres #314

Open
jerrywham opened this issue Jan 15, 2019 · 1 comment
Open

plxUtils::title2url ne prend pas en compte les ancres #314

jerrywham opened this issue Jan 15, 2019 · 1 comment
Assignees
Labels
changes new features

Comments

@jerrywham
Copy link
Contributor

jerrywham commented Jan 15, 2019

Si, dans les pages statiques par exemple, on veut indiquer une ancre à la suite d'une url (du style url#ancre), la méthode plxUtils::title2url modifie le tout en url-ancre.

Pour que cela soit pris en compte, je propose la modification suivante :

        /**
	 * Méthode qui convertit une chaine de caractères au format valide pour une url
	 *
	 * @param	str			chaine de caractères à formater
	 * @return	string		nom d'url valide
	 **/
	public static function title2url($str) {
		$vars = explode('#',$str);
		$url = '';
		foreach ($vars as $key => $value) {
			$str = strtolower(plxUtils::removeAccents($value,PLX_CHARSET));
			$str = preg_replace('/[^[:alnum:]]+/',' ',$str);
			$str = strtr(trim($str), ' ', '-');
			$vars[$key] = $str;
		}
		$url = $vars[0].(isset($vars[1]) ? '#'.$vars[1] : '');
		return $url;
	}
@haruka-7 haruka-7 self-assigned this Jan 16, 2019
@haruka-7 haruka-7 added the changes new features label Jan 16, 2019
@haruka-7 haruka-7 added this to the 6.0 milestone Jan 16, 2019
@jerrywham
Copy link
Contributor Author

Cela fonctionne au niveau de la modification de l'url mais l'ancre est conservée dans la regex de recherche des pages associées (catégories, articles...) et donc aucune page n'est trouvée.
Je ne sais pas ce que ça implique au niveau modification des regex...

@haruka-7 haruka-7 removed this from the 6.0 milestone Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes new features
Projects
None yet
Development

No branches or pull requests

2 participants