1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

Added universal {HERO} shortcode. Default template intended for Bootstrap 4.

This commit is contained in:
Cameron
2020-12-16 16:24:35 -08:00
parent 1fe797b4d5
commit cf1eaf5d3c
6 changed files with 142 additions and 107 deletions

View File

@@ -98,7 +98,7 @@ class hero_ui extends e_admin_ui
// protected $preftabs = array('General', 'Other' );
protected $prefs = array(
'visibility' => array('title'=> LAN_VISIBILITY, 'tab'=>0, 'type'=>'userclass', 'data' => 'str', 'help'=>''),
'visibility' => array('title'=> LAN_VISIBILITY, 'tab'=>0, 'type'=>'userclass', 'data' => 'str', 'help'=>'', 'writeParms'=>array('classlist' => 'public,member,guest,admin,main,classes,nobody, no-excludes')),
'icon_pack' => array('title'=> "Icon Pack", 'tab'=>0, 'type'=>'method', 'data' => 'str', 'writeParms'=>array(),'help'=>''),
'slide_interval' => array('title'=>'Slide Interval', 'type'=>'dropdown', 'data'=>'int', 'writeParms'=>array('optArray'=>array())),
);

View File

@@ -58,10 +58,11 @@ li .hero-list-text {
#carousel-hero.carousel {
position: relative;
left: 0;
top: 0;
top: 30px;
width: 100%;
height: 100%;
overflow: hidden
overflow: hidden;
margin-bottom: 30px;
}
#carousel-hero.carousel .carousel-indicators li {
@@ -78,9 +79,9 @@ li .hero-list-text {
#carousel-hero.carousel .carousel-indicators {
position: static;
width: auto;
display: inline-block;
margin: 0;
text-align: left;
display: block;
margin: 15px;
text-align: center;
}
#carousel-hero.carousel .carousel-indicators li {
@@ -94,7 +95,8 @@ li .hero-list-text {
margin: 2px;
margin-top: 10px;
border-radius: 2px;
cursor: pointer
cursor: pointer;
text-align:center;
}
#carousel-hero.carousel .carousel-indicators li.active {
@@ -103,10 +105,11 @@ li .hero-list-text {
}
#carousel-hero.carousel .carousel-controls {
position: absolute;
left: 20px;
bottom: 20px;
width: 160px
position:relative;
text-align: center;
margin-top: -80px;
width: 100%;
z-index:1000;
}
#carousel-hero.carousel .carousel-controls a {
@@ -125,7 +128,7 @@ li .hero-list-text {
text-align: center;
cursor: pointer;
transition: all ease .5s;
margin-right: 10px;
margin-left: 1rem;
margin-right: 1rem
}
@@ -141,8 +144,8 @@ li .hero-list-text {
}
#carousel-hero.carousel .carousel-controls a.right {
margin-right: 20px;
margin-right: 2rem
margin-right: 0;
margin-right: 1rem
}
#carousel-hero.carousel .carousel-inner {

View File

@@ -0,0 +1,117 @@
<?php
/*
* Copyright (c) e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: e_shortcode.php 12438 2011-12-05 15:12:56Z secretr $
*
* Featurebox shortcode batch class - shortcodes available site-wide. ie. equivalent to multiple .sc files.
*/
if(!defined('e107_INIT'))
{
exit;
}
class hero_shortcodes extends e_shortcode
{
public $override = false; // when set to true, existing core/plugin shortcodes matching methods below will be overridden.
private $active = false;
function __construct()
{
parent::__construct();
$pref = e107::pref('hero');
$this->active = check_class($pref['visibility']);
}
/**
* @param null $parm
* @example {HERO}
* @return string
*/
function sc_hero($parm = null) // Naming: "sc_" + [plugin-directory] + '_uniquename'
{
if(empty($this->active))
{
return null;
}
$text = "";
// if(!empty($parm))
// {
// $text .= print_a($parm,true); // e_menu.php form data.
// }
$data = e107::getDb()->retrieve('hero','*',"hero_class IN(".USERCLASS_LIST.") ORDER BY hero_order",true);
$sc = e107::getScBatch('hero',true, 'hero');
$template = e107::getTemplate('hero','hero','menu');
$tp = e107::getParser();
$totalSlides = count($data);
$default = array('hero_total_slides'=>$totalSlides);
if(!is_object($sc))
{
return "Hero shortcodes failed to load";
}
$sc->setVars($default);
$text = $tp->parseTemplate($template['header'],true, $sc);
foreach($data as $k=>$row)
{
$bullet = e107::unserialize($row['hero_bullets']);
$row['hero_bullets'] = $bullet;
$button1 = e107::unserialize($row['hero_button1']);
$row['hero_button1'] = $button1;
$button2 = e107::unserialize($row['hero_button2']);
$row['hero_button2'] = $button2;
$row['hero_slide_active'] = ($k == 0) ? 'active' : '';
$row['hero_total_slides'] = $totalSlides;
$sc->setVars($row);
$text .= $tp->parseTemplate($template['start'],true,$sc);
foreach($row['hero_bullets'] as $cnt=>$row2)
{
if(empty($row2['text']))
{
continue;
}
$sc->count = $cnt;
$text .= $tp->parseTemplate($template['item'],true,$sc);
}
$text .= $tp->parseTemplate($template['end'],true,$sc);
}
$text .= $tp->parseTemplate($template['footer'], true, $sc);
return $text;
}
}

View File

@@ -13,97 +13,5 @@
if (!defined('e107_INIT')) { exit; }
// $sql = e107::getDB(); // mysql class object
// $tp = e107::getParser(); // parser for converting to HTML and parsing templates etc.
// $frm = e107::getForm(); // Form element class.
// $ns = e107::getRender(); // render in theme box.
//require_once("../../class2.php");
// define('e_IFRAME', true);
//require_once(HEADERF);
$text = "";
if(!empty($parm))
{
// $text .= print_a($parm,true); // e_menu.php form data.
}
$data = e107::getDb()->retrieve('hero','*',"hero_class IN(".USERCLASS_LIST.") ORDER BY hero_order",true);
$sc = e107::getScBatch('hero',true, 'hero');
$template = e107::getTemplate('hero','hero','menu');
$tp = e107::getParser();
$totalSlides = count($data);
$default = array('hero_total_slides'=>$totalSlides);
if(!is_object($sc))
{
return "Hero shortcodes failed to load";
}
$sc->setVars($default);
$text = $tp->parseTemplate($template['header'],true, $sc);
foreach($data as $k=>$row)
{
$bullet = e107::unserialize($row['hero_bullets']);
$row['hero_bullets'] = $bullet;
$button1 = e107::unserialize($row['hero_button1']);
$row['hero_button1'] = $button1;
$button2 = e107::unserialize($row['hero_button2']);
$row['hero_button2'] = $button2;
$row['hero_slide_active'] = ($k == 0) ? 'active' : '';
$row['hero_total_slides'] = $totalSlides;
$sc->setVars($row);
$text .= $tp->parseTemplate($template['start'],true,$sc);
foreach($row['hero_bullets'] as $cnt=>$row2)
{
if(empty($row2['text']))
{
continue;
}
$sc->count = $cnt;
$text .= $tp->parseTemplate($template['item'],true,$sc);
}
$text .= $tp->parseTemplate($template['end'],true,$sc);
}
$text .= $tp->parseTemplate($template['footer'], true, $sc);
$text = e107::getParser()->parseTemplate("{HERO}", true);
e107::getRender()->tablerender(null, $text, 'hero-menu');
/*
$arr = array(
0 => array('caption'=>'Slide 1', 'text'=>'<div class="text-center">Slide 1 text</div>'),
1 => array('caption'=> 'Slide 2', 'text'=> '<div class="text-center">Slide 2 text</div>')
);
$text = e107::getForm()->carousel('my-carousel',$arr);
e107::getRender()->tablerender("Core", print_a($text,true), 'hero-menu');*/
//require_once(FOOTERF);

View File

@@ -210,6 +210,11 @@ class plugin_hero_hero_shortcodes extends e_shortcode
public function sc_hero_button1_label($parm=null)
{
if(empty($this->var['hero_button1']['label']))
{
return null;
}
return e107::getParser()->parseTemplate($this->var['hero_button1']['label'], true);
}

View File

@@ -34,6 +34,7 @@ $HERO_TEMPLATE['menu']['footer'] = '</div><div class="carousel-controls">
$HERO_TEMPLATE['menu']['start'] = '<div class="carousel-item item {HERO_SLIDE_ACTIVE}" style="background-image:url({HERO_IMAGE})">
<div class="container">
<div class="carousel-caption">
<div class="hero-text-container">
<header class="hero-title animated slideInLeft animation-delay-5">
@@ -52,6 +53,7 @@ $HERO_TEMPLATE['menu']['end'] = ' </ul>
</div>
</div>
</div>
</div>
</div>';