Using Theme functions in a plugin

5 views
Skip to first unread message

haijak

unread,
Dec 24, 2009, 4:53:10 PM12/24/09
to habari-users
I'm trying to hack the "RN Monthly Archives" plugin to add a small
function for the theme I'm building.

This line:
if($yr_mth->year == Theme::__get('year') and $yr_mth->month ==
Theme::__get('month')): $crnt = ' class="current"';

Gives this result:
Fatal error: Non-static method Theme::__get() cannot be called
statically, assuming $this from incompatible context

The research I have done leads me to believe that code should work.
But there seams to be something else needed to "initialize" the use of
the Theme class.

I could also be completely wrong. If somebody could help, I would Love
you.
Thanks

Colin

unread,
Jan 3, 2010, 6:24:31 AM1/3/10
to habari...@googlegroups.com
Hi Haijak

I hope I'm not too late in replying.

Unfortunately, your code doesn't have any surrounding context nor is
it in the plugin itself, so I can't see what you are doing or trying
to achieve, but the error you are seeing is technically correct.

The __get() function in theme.php is not a static function, so
shouldn't be called as such.

What you may find will work is to pass the $theme variable to your
function and then try calling __get() non-statically using the ->
operator. For example:

function theme_my_custom_class($theme) {
if($yr_mth->year == $theme->__get('year') and $yr_mth->month ==
$theme->__get('month')): $crnt = ' class="current"';
return $crnt;
}

You would then use this function within your theme using something like:

$theme->my_custom_class();

This is a very crude and over simplified function, but it illustrates
the point and should hopefully steer you in the right direction.

HTH
Colin

> --
> To post to this group, send email to habari...@googlegroups.com
> To unsubscribe from this group, send email to habari-users...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/habari-users

--
Colin Seymour
Blog: http://colinseymour.co.uk
Tech Stuff: http://www.lildude.co.uk
Barefoot Running: http://barefootrunner.co.uk

Reply all
Reply to author
Forward
0 new messages