ZenphotoCMS Forum
printLatestNews - invalid argument - 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: printLatestNews - invalid argument (/thread-6112.html)



printLatestNews - invalid argument - gjr - 2009-11-10

Hi,

I am using the zenpage function printLatestNews() on the index.php page. When I goto page 2 because the album list is paginated I get this error for the latest news:

Warning: Invalid argument supplied for foreach() in F:.......\zp-core\plugins\zenpage\zenpage-template-functions.php on line 1171

I am not sure exactly how pagination works, but it seems this function is trying to list the next x news, but the array is empty on subsequent pages. Is this a bug?

I am using 1.2.6 on a local setup so sorry i cannot provide a link....

Note: I am using the "none" option - just list news (no images)...




printLatestNews - invalid argument - acrylian - 2009-11-10

That function is actually independed and should no be affected by the pagination. Please post how you call the function and where on index.php.




printLatestNews - invalid argument - gjr - 2009-11-10

printLatestNews(4,'none','',true,true,150,true);

I call this on a custom theme, in a "sidebar" on index.php. In the main window is the album loop causing the pagination.




printLatestNews - invalid argument - acrylian - 2009-11-10

I just tried with then zenpage-default theme's sidebar and besides missing correct css setup I could not see any issues. Please try that theme, too. Since you use a custom theme something must be different.




printLatestNews - invalid argument - gjr - 2009-11-11

Hmm. I did the same Acrylian with the same error...

I put:

in sidebar.php in the zenpage-default theme.

On the homepage it appears fine. When I click page 2 on the home page I get the error where the latest news should appear:

Warning: Invalid argument supplied for foreach() in F:......\zp-core\plugins\zenpage\zenpage-template-functions.php on line 1171




printLatestNews - invalid argument - acrylian - 2009-11-11

Sorry, as said I was not able to reproduce it with the current nightly build and the zenpage-default theme.




printLatestNews - invalid argument - gjr - 2009-11-11

Quote:That function is actually independed and should no be affected by the pagination
The function calls this function in zenpage core functions:
function getNewsArticles($articles_per_page='', $category='', $published=NULL)

It makes me think pagination is affecting it, at least for me. I will see if I can get a test site up for you to view...




printLatestNews - invalid argument - acrylian - 2009-11-12

That function is used to get paginated articles but it should not be affected as the number is passed directly to the function and not set automatically.

A demo site would be good as everything else would be guessing.




printLatestNews - invalid argument - gjr - 2009-11-12

Please view the error here, second index page using pagination:

http://www.blueskywebcreations.com/zenphoto/

Default install, activated zenpage, uploaded albums via ftp, created 3 news articles, activated zenpage-default theme, added the following to sidebar.php in zenpage-dafault:

`

`




printLatestNews - invalid argument - acrylian - 2009-11-12

Ok, thanks. I see it and will take a look.




printLatestNews - invalid argument - acrylian - 2009-11-12

Quick update, I was now able to reproduce and it will be fixed in tonight's nightly.




printLatestNews - invalid argument - gjr - 2009-11-13

Solved in nightly, Thanks Acrylian!