You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The v2 plugin inherited a template structure that grew organically and was never
rationalised. Several problems have accumulated:
One $NEWS_TEMPLATE variable is shared by two distinct frontend controllers
(news.php and news_category.php), mixing list and category keys in a single file.
$NEWS_OTHER_TEMPLATE has a misleading name — "other" evokes the legacy
other_news_menu rendering style, when in reality this template holds extras that
accompany a single news item view (related items, navigation, comments).
news.php calls e107::getTemplate('news', 'news') without a merge flag, so
theme overrides require copying the entire template file.
admin_config.php line 1413 calls getTemplate('news', 'news', 'view') — a key
that does not exist in $NEWS_TEMPLATE. The call silently returns false and falls
through to getLayouts(). A bug, not a feature.
Guiding principles
One controller → one template file. A developer opening any frontend controller
can immediately tell which template file drives it.
One menu type → one template key. Themes override only the keys they need;
$merge=true handles the rest.
Variable names describe content, not provenance.$NEWS_EXTRAS_TEMPLATE says
what is in the file; $NEWS_OTHER_TEMPLATE says nothing useful.
getLayouts() keys are user-visible layouts. Sub-components rendered inside a
layout (nav, related, comments) belong in a separate variable so they never appear
in admin dropdowns.
$NEWS_MENU_TEMPLATE['list'] (currently mis-placed in news_template.php lines //not sure about this
15–16, 63) → move to news_menu_template.php under key 'list'
Add $NEWS_LIST_INFO array for getTemplateInfo() (mirrors pattern from
news_view_template.php)
All menu getTemplate calls need consistent true, true (merge + theme override).
File
Line
Current
Change
news.php
L1026, L1386, L1406
no merge flags
add true, true
latestnews_menu.php
L53
true, true ✓
no change
news_archive_menu.php
L32
true, true ✓
no change
news_carousel_menu.php
L29
true, true ✓
no change
news_categories_menu.php
L35
true, true ✓
no change
news_months_menu.php
L110
true, true ✓
no change
other_news_menu.php
L58
true, true ✓
no change
other_news2_menu.php
L54
true, true ✓
no change
e_menu.php
Line
Current
Change
L41
getLayouts('news','news_grid', 'front', ...)
No change — news_grid file name is unchanged
Backward compatibility
news_template.php is the file most likely to be overridden by existing themes.
Recommended approach: keep news_template.php as a shim that includes both new
files and copies keys into the legacy variable:
<?php// news_template.php — backward compatibility shim for v2 themes// Themes should override news_list_template.php or news_category_template.php instead.if (!defined('e107_INIT')) { exit; }
// Load the real files so $NEWS_LIST_TEMPLATE and $NEWS_CATEGORY_TEMPLATE are populatedrequire_once__DIR__ . '/news_list_template.php';
require_once__DIR__ . '/news_category_template.php';
// Expose under the legacy variable name so v2 theme overrides still work$NEWS_TEMPLATE = array_merge($NEWS_LIST_TEMPLATE, ['category' => $NEWS_CATEGORY_TEMPLATE['default']]);
Similarly, news_other_template.php becomes a shim: