Page list pulling content from specific area instance.

Permalink
Hi All,

I'm using some code to pull content from a page into a page list - like a blog index. I'm wondering if its possible to specify which instance of an editable area to pull content from.

Lets say I have 2 content blocks placed in 'My Content Area'. I only want to pull in the content from the second instance - not the first.
-------------------
Start 'My Content Area'

Content Block
------------
Content Block <-- Target this instance of 'My Content Area'

End 'My Content Area'
-------------------

I've attached the code that I'm using. Any help would be appreciated.

<div class="excerpt">
           <?php
             $a = new Area('My Content Area');
             $a->disableControls();
             if($truncateChars) {
               $th = Loader::helper('text');
               ob_start();
                 $a->display($cobj);
               $excerpt = ob_get_clean();
               echo $th->entities($th->shorten($excerpt,$truncateChars));
             } else {
               $a->display($cobj);
             }
           ?>
         </div>

juddc
 
Remo replied on at Permalink Best Answer Reply
Remo
What you probably need is the getBlocks method.

This code returns a list of blocks in the Main area from the current page:
$blocksInArea = Page::getCurrentPage()->getBlocks('Main');


Here are a few more examples about that:http://www.concrete5.org/documentation/developers/blocks/working-wi...