PEAK XOOPS - How to hook XoopsTpl with XCL2.1 in englishin japanese

Archive | RSS |
XOOPS
XOOPS : How to hook XoopsTpl with XCL2.1
Poster : GIJOE on 2007-11-01 06:03:50 (12224 reads)

in englishin japanese
This tips is a part of my session in XCDM#1.

You can hook renderer of XCL2.1 entirely just putting a preload.

First, read the source code of a preload named "HdXoopsTplHook.class.php".

A directory "XOOPS_TRUST_PATH/libs/smartyplugins" is inserted into the top of an array $xoopsTpl->plugins_dir.

This looks like ryusSmartyPluginsEx.
http://ryus.co.jp/modules/wordpress/index.php?p=57

But you should notice the different between addition and insertion.
By insertion, you can also hook almost smarty plugins.

The most important target is resource.db.php.
(I'll show a god sample to hook resource.db.php in the next time)

And the method of hook() also sets the selected theme as "compile_id".

This allows you to select themes with templates for the theme.
Certainly, this looks the same way as the core from xoops.org.

But you should know such a strong hooking is achieved just by adding an extra file. There are no core files overwritten. (Then you can update the core casually)

This is another proof which XCL2.1 has been well-designed definitely.

preload/HdXoopsTplHook.class.php


<?php

class HdXoopsTplHook extends XCube_ActionFilter
{
	function preBlockFilter()
	{
		$this->mRoot->mDelegateManager->add( 'XoopsTpl.New' , array( $this , 'hook' ) ) ;
	}

	function hook( &$xoopsTpl )
	{
		global $xoopsConfig ;

		array_unshift( $xoopsTpl->plugins_dir , XOOPS_TRUST_PATH.'/libs/smartyplugins' ) ;
		$compile_id = $xoopsConfig['template_set'] . '-' . $xoopsConfig['theme_set'] ;
		$xoopsTpl->compile_id = $compile_id ;
		$xoopsTpl->_compile_id = $compile_id ;
	}
}

?>


Printer friendly page Send this story to a friend

Comments list

gigamaster  Posted on 2007/12/15 0:40
Hi,

I test the resource.db.php hack to load theme templates
it's a very easy solution (only tested with legacy modules)
Imagine to personalize almost every 'output' element and
extend with extra smarty plugins... Freedom and Fun !

GIJOE  Posted on 2007/12/13 6:22
Of course, I shall write the next content
suico  Posted on 2007/11/29 19:43
Sorry GIJOE, what is the purpose of hooking? Can you show me an example ? I don t understand the use of it. Is it like the smarty plugins ?
Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!