Theme Shortcodes

Custom theme shortcodes

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

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) 

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.

function sc_theme_path() {
return SITEURL . e_THEME . $this->sitetheme . "/";

}