Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Twitter
Powered by Vanilla. Made with Bootstrap.
Theme built by Kasper Kronborg Isager
Show only last 4 blog posting
  • Maybe easy, but I thought I would ask here. How can I get this to only display the last 4 posting of a subcategory instead of all of the subcategories. I don't want my page to get to long. I used the code that came with feindura, and I don't fully understand php, but I use trial and error. Can you help me.
    if($currentPage['id'] == 10) {
    $feindura->titleAsLink = true;
    $pagesWithDate = $feindura->listPageByDate(true,true,'category',$currentPage['subCategoryId'],50);
    echo '<<br>><<hr>>';
    foreach ($pagesWithDate as $pageWithDate) {
    echo '<<h2>>'.$pageWithDate['title'].'<</h2>>';
    echo $pageWithDate['pageDate'];
    echo $pageWithDate['content'];
    echo '<<br>><<br>><<hr>>';
  • hi,

    first why you use the double <<?

    to show only the last 4 postings you have to count and then break the foreach loop like this:
    $count = 1;
    foreach ($pagesWithDate as $pageWithDate) {
    echo '<h2>'.$pageWithDate['title'].'</h2>';
    echo $pageWithDate['pageDate'];
    echo $pageWithDate['content'];
    echo '<br><br><hr>';
    if($count == 4)
  • Great! Thanks, and I only used the double << on here to get the code to show instead of rendering the code. <br />
  • nice that it helps.
  • Hopefully this will be the last time I have a question on this project. I want to change the more link that is added at the end of the blog posting snippets. I have been crawling files and I haven't found it yet. Can you point me in the direction so that I can change the "... more" to "...interesting"
  • hi Antoinne,

    parameter number 5 ($shortenText) of the listPagesByDate() method says:

    (optional) number of the maximal text length displayed, adds a "more" link at the end or FALSE to not shorten. You can also pass an array: value 1: text length as int, value 2: text string for the link, or a link string.

    e.g. array(23,false), array(23,'read more'), or array(23,'<a href="%href%"'> read more'). (the %href% will be replaced by the pages href)

    So in case you want to add another text just write: array(100,'read more').
    If you want to add a button image or so use array(100,'<a href="%href%"><img ...></a>')

    hope that helps,