ZenphotoCMS Forum
Warning using printLatestNews() on gallery.php - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: Warning using printLatestNews() on gallery.php (/thread-7782.html)



Warning using printLatestNews() on gallery.php - fretzl - 2010-10-30

Zenphoto version 1.3.1.2 6110

I'm using [i]printLatestNews()[/i] 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.




Warning using printLatestNews() on gallery.php - sbillard - 2010-10-30

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.




Warning using printLatestNews() on gallery.php - fretzl - 2010-10-30

Thanks !
Should have known that by now ;-)
Still having a hard time with coding.




Warning using printLatestNews() on gallery.php - fretzl - 2010-10-30

Although...
Isn't printLatestNews() supposed to set it up?




Warning using printLatestNews() on gallery.php - sbillard - 2010-10-30

I would not expect so, What would it set it up to?




Warning using printLatestNews() on gallery.php - fretzl - 2010-10-30

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!




Warning using printLatestNews() on gallery.php - sbillard - 2010-10-30

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.




Warning using printLatestNews() on gallery.php - acrylian - 2010-10-31

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?




Warning using printLatestNews() on gallery.php - fretzl - 2010-10-31

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 [i]gallery.php[/i].

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].




Warning using printLatestNews() on gallery.php - acrylian - 2010-10-31

I will take a look.

edit: Indeed, that's a bug related to the recent change to getContentShorten()




Warning using printLatestNews() on gallery.php - acrylian - 2010-10-31

Should be fixed now.




Warning using printLatestNews() on gallery.php - fretzl - 2010-10-31

Oh yes, working nicely again :-)