Replacement of custom header shortcode form JMT plugin JM_CUSTOM_HEADER

Images
Images
Images
Images

From 2.3.1 up is not possible to work with theme layouts from plugin

You need to move this functionality to theme shortcodes

Add new properties:

private $actualLayoutData= array();
private $sitetheme = '';

Change _construct() to init();

Fill

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

Now change header shortcode:

Simple version:

function sc_header()
{
  $headerName = varset( $this->actualLayoutData['layout_header'] , "header_default");
  $headerpath = THEME . "headers/{$headerName}.html";

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

The extended version is not possible anymore, saving here just for records.

function sc_header($parm)
{
  $text = '';
  if ($parm['header'])
  {
    $headerCode = $parm['header'];
    $headerName = varset( "header_" . $neededheader , "header_default");
  }
  else
  {
    $headerName = varset( $this->actualLayoutData['layout_header'] , "header_default");
  }
  $headerpath = THEME . "headers/{$headerName}.html";

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

This shortcode is specific because it doesn’t need to use parseTemplate() to parse shortcodes.  I think that it is possible to replace {---HEADER---} with theme shortcode with the theme’s parameters, but then parseTemplate() needs to be used. Not tested, short of time.

The version with {---HEADER---}  above is the actual official way how to do it.

10 Years

GLORIOUS YEARS

100%

SATISFACTION RATE

20+

e107 THEMES

10+

e107 PLUGINS

Images