Forum

Thread tagged as: Problem, Configuration

Search shared regions

For some reason no results show up for shared regions here is some example code that I have been using to try and test

example.php

<?php
if (!defined('PERCH_RUNWAY')) include($_SERVER['DOCUMENT_ROOT'].'/cms/runtime.php');

perch_content_create('test', ['shared' => true, 'template'=>'test', 'multiple'=>true, 'edit-mode'=>'list-detail', 'searchable'=>true, 'search-url'=>'/example/{slug}', 'add-to-top'=>true]);
perch_content_custom('test', ['template'=>'test', ]);

text.html

<perch:content id="title" type="text" label="Title" title="true" required="true" />
<perch:content id="slug" type="slug" for="title" label="/example/" editable="true" required="true" suppress="true" />
<perch:content id="description" type="textarea" editor="redactor" html="true" label="Description" />

Fill out the description with some text and then do a search for a word from that text, no results are found.

Andrew Wallace

Andrew Wallace 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Shared regions aren't searched, because they don't have a page to display in the search results.

I don't get it. What is search-url for?

Maby I am not using the shared regions properly but then how wold you have for example a store directory where you list all of the stores and then have sub pages with further store details. I am currently just using shared regions and then have a list of all the stores on /stores and then /stores/{slug} for the detail pages, I use a simple router I wrote and then pass {slug} into perch_content_custom with a filter to pull out the individual store.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

I wouldn't use Shared Regions for that, that's definitely not a use case it was designed for.

Look at this article in the documentation, you want to create a list/detail page: https://docs.grabaperch.com/perch/content/functions/how-do-i-create-list-detail-pages/