e107sk.com

Theme headers

on Sunday 19 April 2020
comments: 0

 New e107 2.3.0

Magic shortcode Meaning Supported (tested) Note
{---HEADER---}
Custom Header in theme.html  header   footer defined in theme shortcodes sc_header()

How is done in our themes:

{---HEADER---} - magic shortcode in theme.html

__construct in theme shortcodes class:

$this->sitetheme = e107::getPref('sitetheme');

Get correct extension (compatibility with older themes):

if (is_readable(e_THEME.$this->sitetheme."/theme.html"))
{
$this->file_extension = ".html"; //change to php if you use php code in header

}
else $this->file_extension = ".php";

With JM Theme plugin installed (variable headers for layouts)

if(e107::isInstalled('jmtheme'))
{
$where = 'layout_theme = "'.$this->sitetheme.'" AND layout_mode = "'.THEME_LAYOUT.'" LIMIT 1 ';
$this->customlayout = e107::getDb()->retrieve('jmlayout', '*', $where );
}

With newer themes, it can be replaced with $this->file_extension = ".html";

/**
* Special Header Shortcode for dynamic menuarea templates.
* @shortcode {---HEADER---}
* @return string
*/
function sc_header()
{
$header = varset( $this->customlayout['layout_header'] , "header_default");
$headerpath = e_THEME. $this->sitetheme.'/headers/'.$header. $this->file_extension;

if(file_exists($headerpath)) {
$text = file_get_contents($headerpath);
}
else $text = '';
return $text;
}

0 Comments

Other links

Follow us