Forum

Thread tagged as: Problem, Runway

Passing Collection Data as a Title

Hi,

I'm trying to pass the title of a collection to be the title of my page. I'm passing the value across ok but I can't get the collection part to successfully populate my variable.

$theTitle = perch_collection('brands',[
        'template' => 'watch/brand_title.html',
        'filter' => 'slug',
        'match'  => 'eq',
        'value'  => perch_get('brand'),
        'count' => 1
    ]);

    perch_layout(
        'global.header',
        array(
            'title' => $theTitle,
            'styles'=>'t3.css'
        )
    );

brand_title.html is then just:

<perch:content id="brand" />

It outputs at the top of the page, rather than passing to the layout. I'm feeling like its a setting to say raw output, but I don't know how to do that.

It does seem rather a lot of code for something relatively simple, if there's a better way please let me know :)

Thanks for your help, Chris.

Chris Comben

Chris Comben 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You need to return the result:

$theTitle = perch_collection('brands',[
        'template' => 'watch/brand_title.html',
        'filter' => 'slug',
        'match'  => 'eq',
        'value'  => perch_get('brand'),
        'count' => 1
    ], true);

Thats the one! I knew it was true somewhere :) thanks.