mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 04:10:38 +02:00
Issue #2678 - Fix merging of theme plugin template when a key is provided.
This commit is contained in:
@@ -2743,7 +2743,7 @@ class e107
|
||||
$path = self::coreTemplatePath($id, $override);
|
||||
$id = str_replace('/', '_', $id);
|
||||
$ret = self::_getTemplate($id, $key, $reg_path, $path, $info);
|
||||
|
||||
|
||||
### Attempt to fix merge issues; in case we override - template array not found in theme,
|
||||
### so we need to continue and merge with core templates
|
||||
if($merge && $override && empty($ret))
|
||||
@@ -2751,7 +2751,7 @@ class e107
|
||||
$ret = array();
|
||||
}
|
||||
|
||||
if((!$merge && !$override) || is_string($ret))
|
||||
if((!$merge && !$override) || is_string($ret))
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
@@ -2762,7 +2762,7 @@ class e107
|
||||
$id = str_replace('/', '_', $id);
|
||||
// Introducing noWrapper when merging
|
||||
$ret_core = self::_getTemplate($id, $key, $reg_path, $path, $info, true);
|
||||
|
||||
|
||||
return (is_array($ret_core) ? array_merge($ret_core, $ret) : $ret);
|
||||
}
|
||||
|
||||
@@ -2812,22 +2812,30 @@ class e107
|
||||
|
||||
$id = str_replace('/', '_', $id);
|
||||
$ret = self::_getTemplate($id, $key, $reg_path, $path, $info);
|
||||
if(!$merge || !$override || !is_array($ret))
|
||||
|
||||
if($merge === false || $override === false)
|
||||
{
|
||||
return $ret;
|
||||
return ($ret === false) ? '' : $ret;
|
||||
}
|
||||
|
||||
// merge
|
||||
$reg_path = 'plugin/'.$plug_name.'/templates/'.$id;
|
||||
$path = self::templatePath($plug_name, $id, false);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$id = str_replace('/', '_', $id);
|
||||
// Introduced noWrapper when merging
|
||||
$ret_plug = self::_getTemplate($id, $key, $reg_path, $path, $info, true);
|
||||
|
||||
if($merge === true && $key !== null && $ret === false) // key not set, so send 'core' version instead.
|
||||
{
|
||||
return $ret_plug;
|
||||
}
|
||||
|
||||
if($ret === false)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return (is_array($ret_plug) ? array_merge($ret_plug, $ret) : $ret);
|
||||
}
|
||||
|
||||
@@ -3041,12 +3049,13 @@ class e107
|
||||
}
|
||||
|
||||
$ret = (!$info ? self::getRegistry($regPath) : self::getRegistry($regPathInfo));
|
||||
|
||||
if(!$key)
|
||||
{
|
||||
return $ret;
|
||||
}
|
||||
|
||||
return ($ret && is_array($ret) && isset($ret[$key]) ? $ret[$key] : '');
|
||||
return ($ret && is_array($ret) && isset($ret[$key]) ? $ret[$key] : false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -29,7 +29,12 @@ foreach($tmp as $id => $val)
|
||||
// e107::getDebug()->log($val);
|
||||
}
|
||||
|
||||
$template = e107::getTemplate('news', 'news_menu', 'archive');
|
||||
$template = e107::getTemplate('news', 'news_menu', 'archive',true, true);
|
||||
|
||||
if(ADMIN && empty($template))
|
||||
{
|
||||
$text = "Missing Template. Check that your theme's news_menu_template.php file contains an 'archive' template. ";
|
||||
}
|
||||
|
||||
foreach($arr as $year=>$val)
|
||||
{
|
||||
@@ -80,10 +85,10 @@ foreach($arr as $year=>$val)
|
||||
foreach($items as $row)
|
||||
{
|
||||
$url = e107::getUrl()->create('news/view/item', $row, array('allow' => 'news_sef,news_title,news_id,category_sef,category_name,category_id'));
|
||||
$var = array('ITEM_URL' => $url,
|
||||
'ITEM_TITLE' => $tp->toHtml($row['news_title'],false,'TITLE'),
|
||||
);
|
||||
$text .= $tp->simpleParse($template['item'], $var);
|
||||
$var = array('ITEM_URL' => $url,
|
||||
'ITEM_TITLE' => $tp->toHtml($row['news_title'],false,'TITLE'),
|
||||
);
|
||||
$text .= $tp->simpleParse($template['item'], $var);
|
||||
}
|
||||
$text .= $template['month_end'];
|
||||
}
|
||||
|
@@ -137,7 +137,7 @@ $NEWS_MENU_TEMPLATE['archive']['year_start'] = "<li>
|
||||
$NEWS_MENU_TEMPLATE['archive']['year_end'] = '</ul></li>';
|
||||
|
||||
$NEWS_MENU_TEMPLATE['archive']['month_start'] = "<li>
|
||||
<a class='e-expandit' href='#{MONTH_ID}'>{MONTH_NAME}<span class='badge'>{MONTH_COUNT}</span></a>
|
||||
<a class='e-expandit' href='#{MONTH_ID}'>{MONTH_NAME}</a>
|
||||
<ul id='{MONTH_ID}' class='news-archive-menu-items' style='display:none'>
|
||||
";
|
||||
$NEWS_MENU_TEMPLATE['archive']['month_end'] = '</ul></li>';
|
||||
|
Reference in New Issue
Block a user