1

This question already has an answer here:

I have an $items array that I was displaying with my template file. Now I want to add a pagination, therefore the code looks like this:

    $current_page = pager_default_initialize(count($items), 4);
    $chunks = array_chunk($items, 4, TRUE);

    return theme('activit_item_list_block', array('title' => $title, 'subtitle' => $subtitle, 'items' => $chunks[$current_page])).
           theme('pager', array('quantity', count($items))); 

but now im getting error:

Fatal error: Allowed memory size of 1342177280 bytes exhausted (tried to allocate 40961 bytes) in C:\xampp\htdocs\grantexpert\includes\theme.inc on line 1514

Can't find out what I'm doing wrong, the code is identical with few examples that i found on internet. There is only 5 items in $items array.

activit_item_list_block:

    <?php $countinrow = 0; $itemcount = count($items); $counter = 0; ?>

    <div id="item-list">

            <div class="description"><?php echo rip_tags($subtitle); ?></div>

            <div class="cont">

                <?php foreach($items as $item) { ?><!-- 

                row 

            --><?php $countinrow++; $counter++; if ($countinrow==1) { ?><div class="row"><?php } ?><!-- 

                        item

                 --><article class="item one-quarter">

                            <img src="http://lorempixel.com/300/110/">

                            <div class="cont">
                                <header>
                                    <h3><?php echo $item['title']; ?></h3>
                                </header>
                                <div class="text">
                                    <?php echo $item['text']; ?>
                                </div>
                            </div>

                            <a class="button btn-small" href="/<?php echo $item['link']; ?>">Viac informácií</a>

                        </article><!-- 

                        END OF item 

             --><?php if ($countinrow==4 || $counter==$itemcount) { $countinrow = 0; ?></div><?php } ?><!-- END OF row 

                <?php } ?>

     --></div>

    </div>

marked as duplicate by kenorb, Adrian Cid Almaguer, Scott Joudry, No Sssweat, Krishna Mohan Mar 16 '16 at 10:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • How big is your data in the first place? And does it happen when you switch to built-in themes? – Mołot Aug 25 '15 at 11:14
  • Data size is minimal, just 5 items with some titles and texts. I updated my question with the template I use. – Incredible Aug 25 '15 at 11:52
1

I'm not sure what theme_activit_item_list_block() is but I suspect you want this:

theme('pager', array('quantity' => count($items)));

instead of this:

theme('pager', array('quantity', count($items))); 
  • I did it but the same result occured. – Incredible Aug 25 '15 at 11:51
  • That's the only obvious error. Unfortunately it's too hard to know the exact cause of memory exhaustion from the given code snippet and error message. – rooby Aug 25 '15 at 11:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.