data-ad-format="auto" data-full-width-responsive="true">

Theme Shortcodes

Theme Shortcodes

Custom theme shortcodes

THEME_PREF- Theme preference as shortcode

Theme_shorcodes.php

mainly used for classes or similar stuff that output HTML code

 var $themePrefs = array();

in _construct.php:

$this->themePrefs = e107::pref('theme');
{THEME_PREF}
function sc_theme_pref($parm = array()) 
{ 
  $name = $parm['name']; 
  if(!isset($name)) 
  { 
    return ""; 
  } 
  $default = varset($parm['default'], '');
  $value = $this->themePrefs[$name]; 
  $value = varset($value, $default); 
  return $value; 
}

Example:

{THEME_PREF: name=header_width&default=container}

Parameters:

code theme preference name
default default value if the pref is not set

Used in:  

LandingZero2 theme 1.4.1 
Cayman theme 1.*

ROW_ODD shortcode

 In theme_shorcodes: 

private $odd = false;

create a new shortcode for needed class

function sc_row_odd()
{
  $this->odd = !$this->odd;
  return ($this->odd) ? '' : 'class= " odd " ';
}

Using in a template: 

<li {ROW_ODD}>

Next examples:

Agency2 theme:

function sc_timeline_inverted()
{
  $this->pairing = !$this->pairing;
  return ($this->pairing ? '' : 'class= "timeline-inverted" ');
}

Used in:

 efiction themes
Agency2
AppStrap

Outdated theme shortcodes for e107 2.3.1

BOOTSTRAP_USERNAV theme shortcode

This shortcode is replaced by {SIGNIN} core shortcode  (Signin) plugin

USERBOX theme shortcode

This shortcode is replaced by {SIGNIN}core shortcode  (Signin) plugin

MEMBER_LOGIN theme shortcode

This shortcode is replaced by {SIGNIN} core shortcode  (Signin) plugin

SITESEARCH theme shortcode

This shortcode is replaced by {NAVBAR_SITESEARCH} theme shortcode  - to be clear it is related to the navbar.  There could be sidebar or footer search forms.

NAVBAR_SITESEARCH

{NAVBAR_SITESEARCH}
/* {NAVBAR_SITESEARCH} */
function sc_navbar_sitesearch() { 
$text = '
<form class="header-top-action" method="get" action="'.e_HTTP.'search.php" >'; 
$text .= "<input type='hidden' name='r' value='0' data-original-title='' /> ";
$text .=' 
<input type="text" class="action-search" placeholder="'.LAN_SEARCH.'" id="q" name="q">
<button type="submit" name="s" class="action-btn">
<i class="fa fa-search"></i></button>
</form>';
return $text;
}

Just copying from theme to theme and changing HTML markup (form class, input class, button class, icon...)  

USED IN

Metis 1.0.x

OUTDATED {SITESEARCH} version:

AppStrap, JMG Services Black & White
Highland Kedavra
Industrial Martik, Martik2

THEME_NEWS_IMAGE - custom news thumbnail

custom THEME_NEWS_IMAGE

At first, I used directly core news image shortcode, but then...  legacy shortcodes file was created, but the template still uses them. What is correct? News_image or newsimage?

So I create custom theme shortcode and used it in news templates...

 /* {THEME_NEWS_IMAGE} */
function sc_theme_news_image( $parm = array() ) // add override of news_image shortcode
{
$sc = e107::getScBatch('news'); 
$data = $sc->getScVar('news_item');
$news_images = explode(',', $data['news_thumbnail']);

$thumbnail = $news_images[0]; 
$thumbnail_src = e107::getParser()->replaceConstants($thumbnail , 'abs');
$class = 'theme-news-image';
$news_category = '<div class="hs-text"><div class="label"><span>'.$data['category_name'].'</span></div></div>';
if($parm['class']) {$class = $parm['class']; } 
$text = '<div class="'.$class.' set-bg" data-setbg="'.$thumbnail_src.'">'.$news_category.'</div>';

return $text;
}

 Used in:

Metis (news image)
Appstrap (news date) 

This shortcode is with the bootstrap3 theme with the name BOOSTRAP_BRANDING. 

/* {NAVBAR_BRANDING} */
function sc_navbar_branding()
{
$pref = e107::pref('theme', 'branding');
switch ($pref)
{
case 'logo':
$brand = '{SITELOGO: h=50}';
break;
case 'sitenamelogo':
$brand = "{SITELOGO: h=50}" . SITENAME;
break;
case 'sitename':
default:
$brand = SITENAME;
break;
}
$text = '<a class="navbar-brand" href="{SITEURL}" alt="{SITENAME}">' . $brand . '</a>';
$text = e107::getParser()->parseTemplate($text);
return $text;
}

Theme pref is needed for this.  Easy way how to avoid using this shortcode:

<a href="{SITEURL}"><img src="{SITELOGO}"></a>
Used:
Metis 
Amin (hardcoded logo), but shortcode is there

THEME_PATH shortcode

Normally in theme.html, you can use {THEME} shortocode for the path to the frontend theme folder.

But it doesn't work in plugin shortcodes, so I added the custom shortcode in theme shortcodes.

<span>    </span><span>/*{THEME_PATH} */</span><span> </span>
<span>    </span><span>function</span><span> </span><span>sc_theme_path</span><span>(</span><span>$</span><span>parm</span><span> </span><span>=</span><span> </span><span>array</span><span>()) </span>
<span>    { </span>
<span>        </span><span>$</span><span>path</span><span> </span><span>=</span><span> </span><span>e_THEME_ABS</span><span>.</span><span>$</span><span>this</span><span>-></span><span>sitetheme</span><span>.</span><span>'/'</span><span>;</span>
<span>        </span><span>return</span><span> </span><span>$</span><span>path</span><span>;</span>
    }