From e9bd0c89363910cb48909fe7ee70826de0e5a4ee Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 29 Sep 2017 11:49:32 -0700 Subject: [PATCH] Issue #2000 set unique ID for each tablerender() of news. Frontend complete. --- class2.php | 1 + e107_plugins/news/news.php | 41 +++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/class2.php b/class2.php index 589d31fd7..ffb2c6322 100644 --- a/class2.php +++ b/class2.php @@ -970,6 +970,7 @@ if (!class_exists('e107table', false)) public function setUniqueId($id) { $this->uniqueId = $id; + return $this; } diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 727007a0e..e57354b51 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -37,6 +37,8 @@ class news_front private $debugInfo = array(); private $cacheRefreshTime = false; private $caption = null; + private $templateKey = null; + private $categorySEF = null; // private $interval = 1; function __construct() @@ -112,7 +114,19 @@ class news_front { if($this->caption !== null) { - e107::getRender()->tablerender($this->caption, $this->text, 'news'); + $tmp = explode('/',$this->route); + $tmp[] = $this->templateKey; + + if(!empty($this->categorySEF)) + { + $tmp[] = $this->categorySEF; + } + + $unique = implode('-',$tmp); + + $this->addDebug("tablerender ID", $unique); + + e107::getRender()->setUniqueId($unique)->tablerender($this->caption, $this->text, 'news'); return true; } @@ -930,8 +944,9 @@ class news_front $text .= ""; } - - $cache_data = e107::getRender()->tablerender($NEWSLISTTITLE, $text, 'news', true); + $this->caption = $NEWSLISTTITLE; + $this->templateKey = 'list'; + $cache_data = $text; // e107::getRender()->tablerender($NEWSLISTTITLE, $text, 'news', true); $this->setNewsCache($this->cacheString, $cache_data); @@ -939,8 +954,6 @@ class news_front return $cache_data; - - } @@ -1510,20 +1523,22 @@ class news_front { $layout = e107::getTemplate('news', 'news'); - // v2.1.7 load the category template if found. if(!empty($newsAr[1]['category_template'])) { - $templateKey = $newsAr[1]['category_template']; - $tmpl = $layout[$templateKey]; + $this->templateKey = $newsAr[1]['category_template']; + $this->categorySEF = $newsAr[1]['category_sef']; + $tmpl = $layout[$this->templateKey]; // $template = $tmpl['item']; - $param['template_key'] = 'news/'.$templateKey; - $this->addDebug('Template key',$templateKey); + $param['template_key'] = 'news/'.$this->templateKey; + $this->addDebug('Template key',$this->templateKey); } elseif($this->action === 'list' && isset($layout['category']) && !isset($layout['category']['body'])) // make sure it's not old news_categories.sc { $tmpl = $layout['category']; + $this->templateKey = 'category'; + // $this->categorySEF = $newsAr[1]['category_sef']; // $template = $tmpl['item']; $param['template_key'] = 'news/category'; $this->addDebug('Template key','category'); @@ -1531,11 +1546,13 @@ class news_front elseif(!empty($layout[$this->defaultTemplate])) { $tmpl = $layout[$this->defaultTemplate]; + $this->templateKey = $this->defaultTemplate; $this->addDebug('Template key',$this->defaultTemplate); } else { $tmpl = $layout['default'] ; + $this->defaultTemplate = 'default'; $this->addDebug('Template key','default'); } // $tmpl = !empty($layout[$this->defaultTemplate]) ? $layout[$this->defaultTemplate] : $layout['default'] ; // default - we show the full items, except for the 'extended' part.. @@ -1546,10 +1563,10 @@ class news_front - if(!empty($tmpl['caption'])) + if(isset($tmpl['caption'])) { $nsc = e107::getScBatch('news')->setScVar('news_item', $newsAr[1])->setScVar('param', $param); - $this->caption = $tp->parseTemplate($tmpl['caption'], true, $nsc); + $this->caption = $tp->parseTemplate($tmpl['caption'], true, $nsc); } if(!empty($tmpl['start'])) //v2.1.5