Forum

Thread tagged as: Question

Display Single Region Item

Hey I'm curious if I can just show a single item from a template using perch_content_custom, without creating a separate template for it. For example, I have property listings, and I want the page title to show just the id="title" from the listing. Instead of creating a separate template with that item and calling it, can I just spit out that item's value in the perch_content_custom array? Thanks for your time!

Jared Medley

Jared Medley 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can either use a template (as you nearly always want to surround it in some sort of markup) or you can use the skip-template option to get the raw data without a template.

Great thank you. So the skip-template returns the raw data, but is there a way to just show the value of one item from the region? Like is there a parameter within the custom array that will return the value of just one item?

Drew McLellan

Drew McLellan 2638 points
Perch Support

No, it returns all the values, so you just pick the one you want.

Cool thanks. I'm having trouble getting skip-template to work in perch_custom. When I add "skip-template" => true, nothing is returned. Is there as example somewhere that I could see of proper usage? I'm sure I'm just leaving out something simple. Thanks!

Drew McLellan

Drew McLellan 2638 points
Perch Support

Show us your code and we can help.

This is inside an include file that checks if the page is a property listing, then will add the listing title. I commented out the skip template line that causes it to break. The page is here: https://hometeaminvestors.com/homes/homeListing.php?item=emerald-estates

<title>
        <?php if( $_PAGE_TYPE == 'listing') {
            perch_content_custom("Home Listings", array(
                "page" => "/homes/index.php",
                "template" => "homeListingName.html",
                "filter"   => "slug",
                "match"    => "eq",
                "value"    => perch_get('item'),
                //"slip-template" => true,
                ));
        } else { perch_pages_title(); }
        ?>
         | 
        <?php perch_content_custom('Large Footer', array(
            'template'=>'companyName.html',
            )); 
            ?>
  </title>
Drew McLellan

Drew McLellan 2638 points
Perch Support

You have a typo - it's skip-template not slip-template.

You also need to assign it somewhere.

$result = perch_content_custom("Home Listings", array(
                "page" => "/homes/index.php",
                "filter"   => "slug",
                "match"    => "eq",
                "value"    => perch_get('item'),
                "skip-template" => true,
                ));