howto vary page pagination in zenpage

I want to have a different number of articles per page then set on the admin tab depending on which news category I am in.

Zenpage documentation gives me a hint: getLimitAndOffset(5);

but code like this does nothing...

`
5 news articles in category blog

<?php getLimitAndOffset(5);

while (next_news()): ;
if (inNewsCategory(blog)){
echo getNewsTitle();
}
endwhile;

printNewsPageListWithNav(gettext('next »'), gettext('« prev'));?>
`
any clues

Comments

  • acrylian Administrator, Developer
    Yes, that code does nothing (it just gets the values for a db query limit and offset), that function is used only internally within the `getNewsArticles` function.

    It's much easier, just use `setOption("zenpage_articles_per_page",,false)` to directly change the option.
    http://www.zenphoto.org/documentation/functions/_functions-basic.php.html#functionsetOption
  • I should have searched better .. thanks Acryllian!

    with getOptionList() I could get a array of all options which are set/can be set?
  • acrylian Administrator, Developer
    Oh, I don't remember the details right now.

    But you find all options of Zenpage within the main `zenpage.php` file (for all other plugins in their main file also) and the standard Zenphoto options are all in `zp-core/setup-option-defaults.php`.
  • I suppose getOptionList() could be used for seeing all the options. Not what it was intended for, though. Optons are somewhat strange beasts since you can have options associated with specific themes and or specific first level options. The list will only give you what is currently active. Best to use the admin options tabs for your exploration.
  • putting

    `setOption("zenpage_articles_per_page",5,false)`

    on the news.php above the while loop does not change the number of articles as set on the admin tab...

    also tried setting other options as in setup-option-defaults.php on my index.php also with no result..
  • acrylian Administrator, Developer
    Hm, it should actually. Don't know right now why not. Please try "true" instead of "false" then the option will not be changed temporarily but the entry will be overwritten directly in the database. Note that you then have to set it always as the original admin entry is not recreated until you save the option there again.
  • just found out that the function `function setOption($key, $value, $persistent=true)` eg `setOption('zenpage_articles_per_page','20','false');` which is also in the functions-basic.php works flawlessly...
  • acrylian Administrator, Developer
    Good. And `false` does actually not need to be within quotes.
  • I am getting somewhere, together with your suggestion in an other thread using getNewsArticles()

    I put together a page that shows only news articles within a defined category and that differs from the default pagination..

    one thing though: the printNewsPageListWithNav() does not stay within the category..
    e.g it shows the pages for all articles.. any hints?
    `
    <?php // news article loop on blog page
    setOption('zenpage_articles_per_page','5','false');
    $results = getNewsArticles('20','blog',NULL);
    foreach ($results as $item) {
    $newsobj = new ZenpageNews($item['titlelink']);
    echo $newsobj->getContent();
    }
    printNewsPageListWithNav(gettext('<'), gettext('>'));
    ?>
    `
  • acrylian Administrator, Developer
    That function relies on a value that is fetched by `getTotalArticles()` (`zenpage-functions.php)` which is only then getting the right total of articles if the global `$_zp_current_category` is set. The category is normally set via the url `$_GET['category']`; Setting `$_zp_current_category = ""` should do the trick. You may also set the context to `ZP_ZENPAGE_NEWS_CATEGORY`. I have never tried this actually.

    May I ask why you do not just call the news.php page by url? That would be much easier than making your own page.
  • BTW, `false` <bold>MUST NOT</bold> be in quotes. Unfortunately `"false"` has the value `true`!!!
  • partially solved it..

    I call to the category by uri on my frontpage eg:

    /zenphoto/news/category/news
    /zenphoto/news/category/blog

    then depending on the category I am in I set the number of articles per page like this

    `
    $check=$_GET['category'];
    if (substr_count($check,"blog")==1){
    setOption('zenpage_articles_per_page','10',false);
    }
    `
    now if I use printNewsPageList() 100 articles get divided over 10 pages in category blog
    thus showing the numbers 1 2 3 4 5 6 7 8 9 10

    but...

    if I use printNewsPageListWithNav()

    I get: 1 2 3 4 5 6 7 8 9 10 next     with page 1 highlighted, which seems correct

    going to page 2 gives

    prev 1 2 3 4 5 6 7 8 9 10 next     with page 2 highlighted, which seems correct

    but.. when being on page 2 and click on prev.. being the printPrevNewsPageLink() function
    this now shows up a page which contains also the articles outside the category I was in eg all articles..

    so actually I am in need of a printPrevNewsWithinCurrentCategoryPageLink()...

    Also in the standard zenpage-default theme going to a category shows indeed all the articles within a category but clicking the titlelink also ends up showing single articles with prev/next articles outside the category you were in..

    `

    `
  • acrylian Administrator, Developer
    You can check what category you are in by using this btw.:
    http://www.zenphoto.org/documentation/plugins/zenpage/_plugins---zenpage---zenpage-template-functions.php.html#functioninNewsCategory

    Actually the pageslist function should do what you want. If it does not we probably have a bug. I will try to reproduce that.

    On your site you are using 1.2.5 RC1. If that is the version you are testing with I have to request to try the current nightly as we are about to release 1.2.7 on Decemeber 1st.
  • acrylian Administrator, Developer
    I just could reproduce the prev page issue that looses the category. So it's a bug.
  • acrylian Administrator, Developer
    Found it, will be fixed in tonight's nightly. Weird, that error seems to have been there unnoticed for quite some time....
  • was just going to post that for testing i do use the nightly... my own website is on a host that doesnt fullfill the latest zenphoto requerements but I run the latest nightly somewhere else for testing

    well if zenphoto would run zenpage instead of wordpress you would have noticed..:-)
  • acrylian Administrator, Developer
    Alright...;-) Btw, the requirements are more recommendations because we can't test lower PHP versions than those stated. Nevertheless it might work on your webspace without problems.
  • Hi Arcylian

    Ugraded to the latest nightly on my testsite ( http://www.thegreenskirt.nl/zenphototest )
    here I have a category blog containing 4 articles and category news containing 3 articles so in total 7 articles.. for testing I set number of articles per page to 1 in admin tab.

    now printNewsPageListWithNav() prev/next stays within category and shows correct numbers of page but...

    going to an single news article from within a category shows printNewsPageListWithNav() with all (eg 7 pages) and prev/next article navigation without regarding the current category
  • acrylian Administrator, Developer
    `printNewsPageListWithNav()` is not meant to be used for single news article display and it should not appear in zenpage-default at all. A single article is never in category context, how could it as it can be in several categories. For the single article navigation there are separate functions which you see on the right (blog article 4) on your page.
  • then line 31 of news.php in zenpage-default theme in nightly should be deleted

    For the single article navigation there are separate functions which you see on the right (blog article 4) on your page.

    you mean the links back to the catogery?

    So if you clicked an article titlelink on the say 7th category page, read the single article and then want to read the next article.. you should go back to the category..browse to the page the article was on and then choose the next article? kind of unlogic to me...
  • acrylian Administrator, Developer
    No, I mean the next/prev article navigation. I don't think these prev/next article links are category sensitive on Wordpress which of course acts as the "State of the art".

    You mean that the category list entry should lead back to the category page the single article is on? Well, that will need a lot of extra GET stuff in the url to get that info over. Not even Wordpress has that.

    I see that line 31 but I do not see the nav if in single article view (see http://zenpage-demo.maltem.de/news/Welcome-to-the-Zenpage-demo - single artice nav is disable because of CombiNews mode)
  • wordpress does regard this with the..'in_same_cat' function option as documented here: http://codex.wordpress.org/Template_Tags/next_post_link

    for now I will make an if condition that omits the prev/next link for a single article link if reached from a category by checking http_referer and instead show a link linking the category link entry back to the category page the single article was on something like this

    `
    in single article code if reached from category listing

    ">Go back to gategory list

    and on news.php in article list code an name anchor on each article

    ">
    `
  • acrylian Administrator, Developer
    Ok, I see, I don't know every Wordpress function. I haven't thought about the http referer, I thought somehow that http referers are not always reliable, so I thought about transfering the data via GET. This "Back to category" linkes seems to be a good idea as an addition.

    If you like open a ticket for it and attach your soltution.
Sign In or Register to comment.