Warning using printLatestNews() on gallery.php

fretzl Administrator, Developer
Zenphoto version 1.3.1.2 [6110](nightly)

I'm using printLatestNews() on gallery.php in a modified Zenpage theme. No problems so far.

But with the latest nightly I suddenly get this warning:
`Warning: get_class() expects parameter 1 to be object, null given in ...\zp-core\zp-extensions\zenpage\zenpage-template-functions.php on line 91`.

Comments

  • The error would be caused by calling this function without a parameter when the variable `$_zp_current_zenpage_news` has not been setup. For instance if you are not in a news loop or on a news page.
  • fretzl Administrator, Developer
    Thanks !
    Should have known that by now ;-)
    Still having a hard time with coding.
  • fretzl Administrator, Developer
    Although...
    Isn't `printLatestNews()` supposed to set it up?
  • I would not expect so, What would it set it up to?
  • fretzl Administrator, Developer
    Sorry I'm at a loss here :-(

    Until a few days ago I was able to use this function anywhere I wanted in Zenpage theme files without any additional coding.

    Btw, thanks for implementing duplication of pages and articles!
  • Sorry, maybe I have confused you. Shortcut answers....

    The error is coming from `getNewsType()`. Guess I had presumed you had looked at line 91. Anyway that function is not called from `printLatestNews()` so I presumed that you thought `printLatestNews()` might be supposed to store something into`$_zp_current_zenpage_news`. It does not and I do not know what it would set it to anyway.
  • acrylian Administrator, Developer
    `printLatestNews` should not require the `$_zp_current_zenpage_news` at all as it is meant to work outside Zenpage context at all (that it has the global definition is probably a leftover).

    How does the code of the theme page look?
  • fretzl Administrator, Developer
    That's what I thought too :-)

    Trying to figure this out I used the standard Zenpage theme and put `printLatestNews()` all the way at the bottom of gallery.php.

    But I think I narrowed it down a bit.
    `getNewsType()`(and subsequently `get_class()`) is called from `getNewsReadMore()`.
    I guess it has something to do with the recent changeset `[6096]`.
  • acrylian Administrator, Developer
    I will take a look.

    edit: Indeed, that's a bug related to the recent change to `getContentShorten()`
  • acrylian Administrator, Developer
    Should be fixed now.
  • fretzl Administrator, Developer
    Oh yes, working nicely again :-)
Sign In or Register to comment.