I am using the cms perch to retrieve data using various functions. I am retrieving product items from various sub pages. The code I have so far is working as it should and can be seen here: http://www.ww.thirdfloordesign.net/products/70mm-couplers/

$raw = perch_pages_navigation(array(
    'from-path'=>'*',
    'skip-template'=>true
));

if (count($raw)) {
    $items = $raw;   
} else {
    // add else statement to output warning 'no products found in this category' or something
}

foreach($items as $item) {
    $product['ID'] = $item['pageNavText'];
    $product['title'] = $item['pageTitle'];
    $product['path'] = $item['pagePath'];
    $product['parent'] = $item['pageSubpagePath'];

    PerchSystem::set_vars(array(
        'product-id'=>$product['ID'],
        'product-title'=>$product['title'],
        'product-path'=>$product['path'],
        'product-parent'=>$product['parent']
    ));

    $product['image'] = perch_content_custom('Image', array(
        'page'=>$product['path'],
        'template'=>'product/_image.html',
        'sort'=>'_order',
        'count'=>1
    ), true);

    PerchSystem::set_var('product-image', $product['image']);

    $items[] = perch_content_custom('Product', array(
        'page'=>$product['path'],
        'template'=>'product/_product.html'
    ), true);
}

Where the data needs to be outputted I am using the following code and it seems to be working as it should except it is also echoing an array which can be seen on the page. Is it because I am using duplicate $variables / array names? Solutions please

<?php
    if (!empty($items)) {
?>
<ul class="product-grid">
<?php
    foreach($items as $item) {
        echo $item;
    }
?>
</ul>
<?php
    } else {
?>
<p class="alert alert-warning"><i class="icon-warning-sign"></i>No products found!</p>
<?php } ?>
share|improve this question
Do you have a var_dump, print_r or similar in your code somewhere that needs to be removed? – Mike Brant Jan 31 at 0:36
$items is 2D, so you will need to nest another loop in there, or access individual keys like $item['pagePath']. print_r($item) to see what's in there. – Michael Berkowski Jan 31 at 0:36
No random var_dump or print_r within page. – Marc Sanders Jan 31 at 0:50

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.