mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 14:46:56 +02:00
News Grid Upgrades (TBD)
This commit is contained in:
@@ -434,7 +434,7 @@ class news_admin_ui extends e_admin_ui
|
||||
'news_id' => array('title' => LAN_ID, 'type' => 'text', 'width' => '5%', 'thclass' => 'center', 'class' => 'center', 'nosort' => false, 'readParms'=>'link=sef&target=blank'),
|
||||
'news_thumbnail' => array('title' => NWSLAN_67, 'type' => 'method', 'data'=>'str', 'width' => '110px', 'thclass' => 'center', 'class' => "center", 'nosort' => false, 'readParms'=>'thumb=60&thumb_urlraw=0&thumb_aw=60', 'readonly'=>false),
|
||||
'news_title' => array('title' => LAN_TITLE, 'type' => 'text', 'data'=>'str', 'tab'=>0, 'writeParms'=> array('required'=> 1, 'size'=>'block-level'), 'inline'=>true, 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_summary' => array('title' => LAN_SUMMARY, 'type' => 'text', 'data'=>'str', 'tab'=>0, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false),
|
||||
'news_summary' => array('title' => LAN_SUMMARY, 'type' => 'text', 'data'=>'str', 'tab'=>0, 'inline'=>true, 'writeParms'=>'size=block-level', 'width' => 'auto', 'thclass' => 'left', 'class' => 'left', 'nosort' => false),
|
||||
'news_body' => array('title' => "", 'type' => 'method', 'data'=>'str', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
'news_extended' => array('title' => "", 'type' => null, 'data'=>'str', 'tab'=>0, 'nolist'=>true, 'writeParms'=>'nolabel=1','data'=>'str', 'width' => 'auto', 'thclass' => '', 'class' => null, 'nosort' => false),
|
||||
|
||||
|
@@ -715,11 +715,18 @@ class e_news_tree extends e_front_tree_model
|
||||
$start = $parser->parseTemplate($template['start'], true, $vars); // must be here in case {SETIMAGE} is present and used for items below.
|
||||
}
|
||||
|
||||
|
||||
$featuredCount = !empty($parms['featured']) ? intval($parms['featured']) : 0;
|
||||
|
||||
e107::getDebug()->log("Featured Count: ".$featuredCount);
|
||||
|
||||
|
||||
foreach ($items as $news)
|
||||
{
|
||||
$vars->counter = $i;
|
||||
$batch->setScVar('news_item', $news->getData());
|
||||
$ret[] = $parser->parseTemplate($template['item'], true, $batch, $vars);
|
||||
$tmpl = (isset($template['featured']) && $i <= $featuredCount) ? 'featured' : 'item';
|
||||
$ret[] = $parser->parseTemplate($template[$tmpl], true, $batch, $vars);
|
||||
$i++;
|
||||
}
|
||||
|
||||
@@ -912,6 +919,8 @@ class e_news_category_tree extends e_front_tree_model
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$ret = array();
|
||||
$tp = e107::getParser();
|
||||
|
||||
@@ -926,7 +935,8 @@ class e_news_category_tree extends e_front_tree_model
|
||||
}
|
||||
$bullet = defined('BULLET') ? THEME_ABS.'images/'.BULLET : THEME_ABS.'images/bullet2.gif';
|
||||
$obj = new e_vars(array('bullet' => $bullet));
|
||||
|
||||
|
||||
|
||||
foreach ($this->getTree() as $cat)
|
||||
{
|
||||
$obj->active = '';
|
||||
@@ -934,8 +944,9 @@ class e_news_category_tree extends e_front_tree_model
|
||||
{
|
||||
$obj->active = ' active';
|
||||
}
|
||||
|
||||
|
||||
$ret[] = $cat->toHTML($template['item'], $parsesc, $obj);
|
||||
|
||||
}
|
||||
|
||||
if($ret)
|
||||
|
@@ -56,6 +56,7 @@ class news_menu
|
||||
$fields['source'] = array('title'=> "Source", 'type'=>'dropdown','writeParms'=>array('optArray'=>$sources), 'help'=>"Assigned items are those with a template assigned to 'News Grid Menu' ");
|
||||
$fields['layout'] = array('title'=> "Layout", 'type'=>'method', 'writeParms'=>'');
|
||||
$fields['count'] = array('title'=> "Number of Items to Display", 'type'=>'number', 'writeParms'=>array('pattern'=>'[0-9]*', 'default'=>4));
|
||||
$fields['feature'] = array('title'=> "Number of Feature Items", 'type'=>'number', 'writeParms'=>array('pattern'=>'[0-9]*', 'default'=>0));
|
||||
$fields['titleLimit'] = array('title'=> "Title Character Limit", 'type'=>'number', 'writeParms'=>'');
|
||||
$fields['summaryLimit'] = array('title'=> "Summary Character Limit", 'type'=>'number', 'writeParms'=>'');
|
||||
|
||||
|
@@ -15,8 +15,9 @@ if (!defined('e107_INIT')) { exit; }
|
||||
* @param string $parm['source'] latest (latest news items) | sticky (news items) | template (assigned to news-grid layout)
|
||||
* @param integer $parm['order'] n.news_datestamp DESC
|
||||
* @param integer $parm['limit'] 10
|
||||
* @param string $parm['template'] default | or any key as defined in news_grid_template.php
|
||||
*
|
||||
* @example hard-coded {MENU: path=news/news_grid&limit=6&source=latest}
|
||||
* @example hard-coded {MENU: path=news/news_grid&limit=6&source=latest&featured=2&template=other}
|
||||
* @example admin assigned - Add via Media-Manager and then configure.
|
||||
*/
|
||||
$cacheString = 'nq_news_grid_menu_'.md5(serialize($parm));
|
||||
@@ -43,14 +44,29 @@ if(false === $cached)
|
||||
$parms['caption'] = $parms['caption'][e_LANGUAGE];
|
||||
}
|
||||
|
||||
if(defset($parms['caption']))
|
||||
if(!empty($parms['caption']) && defined($parms['caption']))
|
||||
{
|
||||
$parms['caption'] = constant($parms['caption']);
|
||||
}
|
||||
|
||||
|
||||
$ntree = e107::getObject('e_news_tree', null, e_HANDLER.'news_class.php');
|
||||
$template = e107::getTemplate('news', 'news_menu', 'grid');
|
||||
$ntree = e107::getObject('e_news_tree');
|
||||
|
||||
if($legacyTemplate = e107::getTemplate('news', 'news_menu', 'grid')) // BC
|
||||
{
|
||||
$template = $legacyTemplate;
|
||||
$parms['tmpl'] = 'news_menu';
|
||||
$parms['tmpl_key'] = 'grid';
|
||||
}
|
||||
else // New in v2.1.5
|
||||
{
|
||||
$tmpl = !empty($parms['template']) ? $parms['template'] : 'default';
|
||||
$template = e107::getTemplate('news', 'news_grid', $tmpl);
|
||||
$parms['tmpl'] = 'news_grid';
|
||||
$parms['tmpl_key'] = $tmpl;
|
||||
|
||||
}
|
||||
|
||||
$gridSize = vartrue($parms['layout'],'col-md-4');
|
||||
|
||||
$parmSrch = array(
|
||||
@@ -61,16 +77,15 @@ if(false === $cached)
|
||||
|
||||
$parmReplace = array(
|
||||
$gridSize,
|
||||
vartrue($parms['titleLimit'],0),
|
||||
vartrue($parms['summaryLimit'],0)
|
||||
vartrue($parms['titleLimit'], 0),
|
||||
vartrue($parms['summaryLimit'], 0)
|
||||
);
|
||||
|
||||
$template = str_replace($parmSrch , $parmReplace, $template);
|
||||
|
||||
$render = (empty($parms['caption'])) ? false: true;
|
||||
|
||||
$parms['tmpl'] = 'news_menu';
|
||||
$parms['tmpl_key'] = 'grid';
|
||||
|
||||
|
||||
if(empty($parms['count']))
|
||||
{
|
||||
@@ -81,14 +96,22 @@ if(false === $cached)
|
||||
|
||||
|
||||
$treeparm = array();
|
||||
if(vartrue($parms['count'])) $treeparm['db_limit'] = '0, '.intval($parms['count']);
|
||||
|
||||
if(!empty($parms['count']))
|
||||
{
|
||||
$treeparm['db_limit'] = '0, '.intval($parms['count']);
|
||||
}
|
||||
|
||||
if(!empty($parms['limit']))
|
||||
{
|
||||
$treeparm['db_limit'] = '0, '.intval($parms['limit']);
|
||||
}
|
||||
|
||||
if(vartrue($parms['order'])) $treeparm['db_order'] = e107::getParser()->toDb($parms['order']);
|
||||
if(!empty($parms['order']))
|
||||
{
|
||||
$treeparm['db_order'] = e107::getParser()->toDb($parms['order']);
|
||||
}
|
||||
|
||||
$parms['return'] = true;
|
||||
|
||||
if(varset($parms['source']) == 'template')
|
||||
@@ -102,6 +125,7 @@ if(false === $cached)
|
||||
}
|
||||
|
||||
$cached = $ntree->loadJoinActive(vartrue($parms['category'], 0), false, $treeparm)->render($template, $parms, $render);
|
||||
|
||||
e107::getCache()->set($cacheString, $cached);
|
||||
}
|
||||
|
||||
|
77
e107_plugins/news/templates/news_grid_template.php
Normal file
77
e107_plugins/news/templates/news_grid_template.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* e107 website system
|
||||
*
|
||||
* Copyright (C) 2008-2017 e107 Inc (e107.org)
|
||||
* Released under the terms and conditions of the
|
||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
$NEWS_GRID_TEMPLATE['default']['start'] = '<div class="row news-grid-default news-menu-grid">';
|
||||
|
||||
$NEWS_GRID_TEMPLATE['default']['featured'] = '<div class="row featured">
|
||||
<div class="col-sm-12">
|
||||
<div class="item col-sm-6" >
|
||||
{SETIMAGE: w=600&h=400&crop=1}
|
||||
{NEWSTHUMBNAIL=placeholder}
|
||||
</div>
|
||||
<div class="item col-sm-6">
|
||||
<h3>Featured {NEWSTITLE: limit=_titleLimit_}</h3>
|
||||
<p>{NEWSMETADIZ: limit=100}</p>
|
||||
<p class="text-right"><a class="btn btn-primary btn-othernews" href="{NEWSURL}">' . LAN_READ_MORE . '</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
';
|
||||
|
||||
$NEWS_GRID_TEMPLATE['default']['item'] = '<div class="item {NEWSGRID}">
|
||||
{SETIMAGE: w=400&h=400&crop=1}
|
||||
{NEWSTHUMBNAIL=placeholder}
|
||||
<h3>{NEWSTITLE: limit=_titleLimit_}</h3>
|
||||
<p>{NEWSSUMMARY: limit=_summaryLimit_}</p>
|
||||
<p class="text-right"><a class="btn btn-primary btn-othernews" href="{NEWSURL}">' . LAN_READ_MORE . '</a></p>
|
||||
</div>';
|
||||
|
||||
$NEWS_GRID_TEMPLATE['default']['end'] = '</div>';
|
||||
|
||||
|
||||
|
||||
//@todo find a better name than 'other'
|
||||
$NEWS_GRID_TEMPLATE['other']['start'] = '<div class="row news-grid-other">';
|
||||
|
||||
$NEWS_GRID_TEMPLATE['other']['featured'] = '<div class="featured item col-sm-6" >
|
||||
{SETIMAGE: w=600&h=400&crop=1}
|
||||
{NEWSTHUMBNAIL=placeholder}
|
||||
<h3>Featured {NEWSTITLE: limit=_titleLimit_}</h3>
|
||||
<p>{NEWSSUMMARY}</p>
|
||||
</div>
|
||||
|
||||
|
||||
';
|
||||
|
||||
|
||||
$NEWS_GRID_TEMPLATE['other']['item'] = '<div class="item col-sm-6">
|
||||
{SETIMAGE: w=120&h=120&crop=1}
|
||||
<ul class="media-list">
|
||||
<li class="media">
|
||||
<div class="media-left media-top">
|
||||
<a href="#">
|
||||
{NEWS_IMAGE: class=media_object img-rounded}
|
||||
</a>
|
||||
</div>
|
||||
<div class="media-body">
|
||||
<h4 class="media-heading">{NEWSTITLE: limit=_titleLimit_}</h4>
|
||||
<p>{NEWSSUMMARY: limit=_summaryLimit_}</p>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>';
|
||||
|
||||
|
||||
|
||||
|
||||
$NEWS_GRID_TEMPLATE['other']['end'] = '</div>';
|
||||
|
@@ -86,15 +86,7 @@ $NEWS_MENU_TEMPLATE['other2']['end'] = "</ul>";
|
||||
|
||||
|
||||
// Grid Menu
|
||||
$NEWS_MENU_TEMPLATE['grid']['start'] = '<div class="row news-menu-grid">';
|
||||
$NEWS_MENU_TEMPLATE['grid']['item'] = '<div class="item {NEWSGRID}">
|
||||
{SETIMAGE: w=400&h=400&crop=1}
|
||||
{NEWSTHUMBNAIL=placeholder}
|
||||
<h3>{NEWSTITLE: limit=_titleLimit_}</h3>
|
||||
<p>{NEWSSUMMARY: limit=_summaryLimit_}</p>
|
||||
<p class="text-right"><a class="btn btn-primary btn-othernews" href="{NEWSURL}">'.LAN_READ_MORE.'</a></p>
|
||||
</div>';
|
||||
$NEWS_MENU_TEMPLATE['grid']['end'] = '</div>';
|
||||
// Moved to news_grid_template.php
|
||||
|
||||
|
||||
// $NEWS_MENU_WRAPPER['grid']['NEWSTITLE'] = "<span style='color:red'>{---}</span>"; // example
|
||||
|
@@ -1287,7 +1287,7 @@ li.rssRow > div {
|
||||
.selectize-input > input, .selectize-input.full { color: inherit; background-color:inherit}
|
||||
.selectize-control div.item { border-radius:3px; }
|
||||
.selectize-control div.item .remove { margin-top:3px }
|
||||
.selectize-input.focus { }
|
||||
.selectize-input.focus { box-shadow: inherit; }
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -153,8 +153,8 @@ li.dropdown-submenu.lower ul.submenu-start li a { display:inline-block; padding-
|
||||
li.dropdown-submenu.lower ul.submenu-start li a:hover { background:none}
|
||||
li.dropdown-submenu.lower ul.submenu-start li:hover { background-color:#f5f5f5; }
|
||||
|
||||
|
||||
|
||||
.news-grid-default .featured { margin-bottom:30px; }
|
||||
.news-grid-other .featured { margin-bottom:30px; }
|
||||
|
||||
/* CUSTOM Responsive Styles */
|
||||
|
||||
|
Reference in New Issue
Block a user