printLatestNews - invalid argument

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

Comments

  • acrylian Administrator, Developer
    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(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.
  • acrylian Administrator, Developer
    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.
  • Hmm. I did the same Acrylian with the same error...

    I put:
    <?php printLatestNews( 4,'none','',true,true,150,true ); ?>
    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
  • acrylian Administrator, Developer
    Sorry, as said I was not able to reproduce it with the current nightly build and the zenpage-default theme.

  • 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...
  • acrylian Administrator, Developer
    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.
  • 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:

    `

    <?php if(function_exists("printLatestNews")) { ?>

    <?php echo gettext("Latest News"); ?>

    <?php printLatestNews( 4,'none','',true,true,150,true ); ?>



    <?php } ?>

    `
  • acrylian Administrator, Developer
    Ok, thanks. I see it and will take a look.
  • acrylian Administrator, Developer
    Quick update, I was now able to reproduce and it will be fixed in tonight's nightly.
  • Solved in nightly, Thanks Acrylian!
Sign In or Register to comment.