0
일부 내용의 링크로 {twitter}demo_user{/twitter}
및 {facebook}demo_user{/facebook}
을 대체하기 위해이 joomla 플러그인을 구현하려고합니다.Joomla 교체 태그
<?php
defined('_JEXEC') or die('Access Deny');
class plgContentSocial extends jplugin
{
function onContentPrepare($context, $article, $params, $limit)
{
preg_match_all('/{twitter}(.*?){\/twitter}/is', $article->text, matches)
$i=0;
foreach ($matches[0] as $match) {
$twitter_username=$matches[1][$1];
$article->text=str_replace($match, '<a href="http://twitter.com/'.$twitter_username.'"follow me on twitter</a>', $article->tex)
$i++
}
preg_match_all('/{facebook}(.*?){\/facebook}/is', $article->text, matches)
$i=0;
foreach ($matches[0] as $match) {
$facebook_username=$matches[1][$1];
$article->text=str_replace($match, '<a href="http://facebook.com/'.$facebook_username.'"follow me on facebook</a>', $article->tex)
$i++
}
}
}
?>
내 문제는 : 어떻게 {social type=twitter}demo_user{/social}
및 {social type=facebook}demo_user{/social}
같은 것을 사용할 수 있습니까? 모든 소셜 네트워크에 대해 preg_match_all
을 반복하고 싶지 않습니다. 그것을 성취 할 수있는 방법이 있습니까?
지도 주셔서 대단히 감사합니다.