xoops forums

xoopdio

Just popping in
Posted on: 2011/11/24 9:56
xoopdio
xoopdio (Show more)
Just popping in
Posts: 29
Since: 2011/9/27
#1

code interception

Hello

I'd like to intercept the code, to make a treatment on the user and main menu links after that the template has made its job (fill and render the block content) but before the sending to the user.

Or in other words : I'd like to transform a link from the user menu for example from that :

<a class="menuMain " title="Private Messaging" href="http://www.xoops.try/modules/pm/">Private Messaging</a>

to this :

<a class="menuMain href="http://www.xoops.try/modules/pm/" title="Private Messaging" onmouseover="showmenu('menu_1');" onfocus="showmenu('menu_1');">Private Messaging<span> :</span></a>

All while staying in the theme modifications capabilities (without modifying code elsewhere), I thought about php dom modifications but I don't see where to place the interception.

Does anyone knows if it is possible and if yes, where can I do that ?

Thank you
"A tree is made of non-tree elements" Thich Nhat Hanh

wishcraft

Module Developer
Posted on: 2011/11/26 17:57
wishcraft
wishcraft (Show more)
Module Developer
Posts: 3670
Since: 2007/5/18
#2

Re: code interception

Yeah annuaki, all you have to do is edit the mainmen and usermenu block template in system. You can for example if you want it for just a user have an if clause seperating one menu for anonomous, one for users and one for admin like so


<{if $xoops_isuser}>

   <{if 
$xoops_isadmin}>

<!-- 
admin smarty template here -->


   <{else}>


<!-- 
standard user template here -->

   <{/if}>

<{else}>

<!-- 
anonymous template here -->


<{/if}>

Resized Image
www.ohloh.net/accounts/226400

Follow, Like & Read:-

twitter.com/SimonASaies
sourceforge.net/projects/chronolabs/
facebook.com/mynamesnot

trabis

Core Developer
Posted on: 2011/11/27 16:40
trabis
trabis (Show more)
Core Developer
Posts: 2268
Since: 2006/9/1 1
#3

Re: code interception

It is possible to hook just after the blocks generation and manipulate the objects(blocks), all you need is a preload.

'Defacer' module has a preload that is able to assign blocks to a smarty var and unset those blocks from the blocks array(so they do not show in on the blocks layout). You can look into it for ideas.

The defacer method is:
function eventCoreClassTheme_blocksRetrieveBlocks($args)

The preload is being triggered in class/theme_blocks.php method retriveBlocks()

xoopdio

Just popping in
Posted on: 2011/11/28 5:36
xoopdio
xoopdio (Show more)
Just popping in
Posts: 29
Since: 2011/9/27
#4

Re: code interception

Quote:
Yeah annuaki




Quote:
all you have to do is edit the mainmen and usermenu block template in system.


Thanks but it's actually what I didn't want to do : I'd like to keep it simple, like in a theme installation, for the user convenience.

Quote:
'Defacer' module has a preload that is able to assign blocks to a smarty var and unset those blocks from the blocks array(so they do not show in on the blocks layout). You can look into it for ideas.


Thanks for the tip, I'll need to have a look but it seems to look more to what I need.

I actually find on the smarty forum another one which would involved a outputfilter plugin but I still need, too, to figure out how to insert it in the application.

With all that, I should work out something. Thanks again.
"A tree is made of non-tree elements" Thich Nhat Hanh