เรียกดู cache โดย
โค้ด: เลือกทั้งหมด
$cache = JFactory::getCache('ชื่อแคชที่ต้องการ');
Moderator: mindphp, ผู้ดูแลกระดาน
โค้ด: เลือกทั้งหมด
$cache = JFactory::getCache('ชื่อแคชที่ต้องการ');
โค้ด: เลือกทั้งหมด
<?php
/**
{{LICENSE}}
*/
defined('_JEXEC') or die;
class PlgContentMlinkarticle extends JPlugin
{
public function onContentPrepare($context, &$row, &$params, $page = 0)
{
JHTML::_('behavior.tooltip');
//$profiler = new JProfiler();
//echo $profiler->mark('Start <br />');
$cache = JFactory::getCache('mlinkarticle');
// $cache->setCaching(true);
$store = unserialize($cache->_getStorage()->get($row->id, 'mlinkarticle'));
if(!empty($store)) {
$row->text = $store;
} else {
$regex = '/href\=\"index\.php\?option\=com\_content&view\=article&id=([0-9]*)/i';
$matches = array();
preg_match_all($regex, $row->text, $matches);
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, title, introtext')->from('#__content');
$db->setQuery($query);
$db->query();
$content = $db->loadObjectList('id');
$loop = count($matches[0]);
if($loop > 0) {
for($i = 0; $i < $loop; $i++) {
$id = $matches[1][$i];
if(isset($content[$id])) {
$tip = $content[$id]->title.'::'.substr(htmlentities($content[$id]->introtext), 0, 25).'...';
$row->text = str_replace($matches[0][$i], 'class="hasTip" title="'.$tip.'" '.$matches[0][$i], $row->text);
$row->text = str_replace('{--mlinkarticle--}', '', $row->text);
$row->text = str_replace('{--mlinkarticle='.$id.'--}', '', $row->text);
}
}
}
$cache->store($row->text, $row->id);
}
//echo $profiler->mark('Finish <br />');
}
}
โค้ด: เลือกทั้งหมด
$cache->setCaching( 'ชื่อcacheที่เซตโดยที่เราตั้งเอง' );
โค้ด: เลือกทั้งหมด
$cache = JFactory::getCache('ชื่อcacheเดียวกับตอนเซตcache');
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 43