Forum

Thread tagged as: Question, Runway

Retrieve single value without template

Is there a way to grab a single value from the database without passing it through a template, then output it to a page?

The example would be to return the heading of a post where the heading is in its own header.php layout. I can make a template with something like <perch:content id="title" type="text" /> but it would be more efficient if I could just output this value straight from the database to the page.

I'm using perch_collection, but I guess it would be the same for perch_content_custom if it's possible. But maybe it's not :P Or maybe it's not a good idea.

Thanks for keeping me right :)

Martin Underhill

Martin Underhill 5 points

  • 5 years ago

I know you can do this with perch_content_custom. Is that any help?

$result = perch_content_custom('Region Name', array('skip-template'=>'true'));
print($result[0]["fieldid"]);

Right on the money! Cheers Clive :D

$result = perch_collection('Work', [
  'filter' => 'slug',
  'match' => 'eq',
  'value' => perch_get('s'),
  'skip-template'=>'true',
]);
print($result[0]["title"]);