Jump to content


Photo

Passing arguments to module function


  • Please log in to reply
1 reply to this topic

#1 nikola

nikola

    Sr. Member

  • Members
  • PipPipPipPip
  • 253 posts
  • 216

  • LocationZagreb, Croatia

Posted 04 December 2011 - 12:03 PM

How can I pass arguments from template to a function that resides in the module?

I'm making a new module and can't figure it out...

Normally if I use a function directly in template(s), I can do the following:

echo function($1, $2, $, $4);

where $1, $2, $3, $4 are arguments passed to a function.

Modules: MarkupYahooWeather / Admin Themes: AdminThemeModesta


#2 Soma

Soma

    Hero Member

  • Moderators
  • 6,267 posts
  • 5469

  • LocationSH, Switzerland

Posted 04 December 2011 - 12:27 PM

In the module's hook function you can do something like this:

<?php
public function someCustomFunction( HookEvent $event ) {
		 
	// get page object
	$page = $event->object;
		
	// get first argument
	$some_id = (int) $event->arguments[0];

	// current language
	$lang = $event->arguments[1];

@somartist | modules created | support me, flattr my work flattr.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users