Forums / Cotonti / Core Labs / set metas from standalone plugin

dervan
#8889 2009-02-26 04:56
# Orkan : no offence, fella
no dust, guy :)


# Orkan : Im only talking about possible programming solution, ...
bla bla bla, i see


=======


# Kilandor : The only way that moving where header is included would be if a plugin used any data generated by header, which is possible. Then it would completely break it, I truthfully don't know any off hand like this, but it may break future things like a more updated Whoisonline tracking method.

I can see the reason for moving it, but it doesn't solve all the problems. Also do remember this, we will be getting more advanced hooking methods, so that a hook is only loaded on certain pages/area's. By moving the header all it does is save that hook, and in some cases yes maybe extra processing.

well

solution:
add new hook - standapart

will change metas from standapart plugin only
standalone plugin will work as before


modified code in system/core/plug/plug.inc.php:
	if (is_array($sed_plugins))
	{
		foreach($sed_plugins as $i => $k)
		{
			if (($k['pl_hook']=='standapart' || $k['pl_hook']=='standalone') && $k['pl_code']==$e)
			{ $out['subtitle'] = $k['pl_title']; }
		}
	}

	$out['subtitle'] = (empty($L['plu_title'])) ? $out['subtitle'] : $L['plu_title'];
	$sys['sublocation'] = $out['subtitle'];

	/* ============= */

	$extp0 = array();
	$extp1 = array();

	if (is_array($sed_plugins))
	{
		foreach($sed_plugins as $i => $k)
		{
			if ($k['pl_code']==$e)
			{
				if ($k['pl_hook']=='standapart')
				{ $extp0[$i] = $k; }
				if ($k['pl_hook']=='standalone')
				{ $extp1[$i] = $k; }
			}
		}
	}

	if (count($extp0)==0 && count($extp1)==0)
	{
		header("Location: " . SED_ABSOLUTE_URL . sed_url('message', "msg=907", '', true));
		exit;
	}

	$t_plug = new XTemplate($path_skin);

	if (count($extp0)>0)
	{
		$extp1 = array(); // disallow standalone hook
		$t = $t_plug;
		foreach($extp0 as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); }
		unset($t);
	}

	require_once $cfg['system_dir'] . '/header.php';

	unset($t);
	$t = $t_plug;

	if (count($extp1)>0)
	{ foreach($extp1 as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }

	if ($autoassigntags)
	{
		$plugin_title = (empty($plugin_title)) ? $L['plu_title'] : $plugin_title;

		if($cfg['homebreadcrumb'])
		{
			$bhome = '<a href="'.$cfg['mainurl'].'">'.sed_cc($cfg['maintitle']).'</a> '.$cfg['separator'].' ';
		}
		else
		{
			$bhome = '';
		}

		$t-> assign(array(
			"PLUGIN_TITLE" => $bhome . '<a href="'.sed_url('plug', "e=$e").'">'.$plugin_title."</a>",
			"PLUGIN_SUBTITLE" => $plugin_subtitle,
			"PLUGIN_BODY" => $plugin_body
		));
	}

	$t->parse("MAIN");
	$t->out("MAIN");
	unset($t, $t_plug);

	require_once $cfg['system_dir'] . '/footer.php';


in system/core/admin/admin.plug.inc.php: replace this string
		$sql3 = sed_sql_query("SELECT pl_code FROM $db_plugins WHERE pl_hook='standalone'");
with
		$sql3 = sed_sql_query("SELECT pl_code FROM $db_plugins WHERE pl_hook='standapart' OR pl_hook='standalone'");


this code is tested and works
This post was edited by dervan (2009-02-28 20:53, 15 years ago)