BFD Calendar

Search question

Recommended Posts

Example: http://www.birthfactdeathcalendar.net/bfd_processwire/search/?q=ballard returns only one page, from the category 'people'.

However, in the category 'Events' there are three pages that also refer to 'ballard' (they are listed as related events on the individual 'people' pages).

In the 'event' template the names are called from the pages in the 'people' category by matching the page id:

        <?php
        $namepage = $pages->get("template=bfd_people, id=$page->bfd_events_people_id");
        $occupation = ucfirst($namepage->bfd_people_occupation->title);
        if($namepage->bfd_people_original) {
		$originally = ", originally " . $namepage->bfd_people_original;
		};
		if($namepage->bfd_people_alias) {
		$alias = " aka " . $namepage->bfd_people_alias;
		};
        echo "<b><a href='{$namepage->url}'>{$occupation} {$namepage->bfd_people_name_first} {$namepage->bfd_people_name_middle} {$namepage->bfd_people_name_last}{$originally}{$alias} </a></b>";
?>

Is there a way to also find the three 'events' from the search box?

More complex: http://www.birthfactdeathcalendar.net/bfd_processwire/search/?q=ballard+london shows no results.

While there is an event about Ballard in London: http://www.birthfactdeathcalendar.net/bfd_processwire/events/3-april-1970/....
 

(Sorry for the quirky design, I want to have the site structure working first.)

Share this post


Link to post
Share on other sites

Check the selector in your search.php file - chance are it doesn't include the require fields that you are storing this information in. Change the selector to include those and you should be fine.

Share this post


Link to post
Share on other sites

As you can see in the php code from the 'event' template the 'people' and 'places' information is not stored there but called from the 'people' and 'places' templates respectively.

$pages->get("template=bfd_people, id=$page->bfd_events_people_id");

In the example above "ballard" is only in the 'title' and 'bfd_people_name_last' fields of the 'people' template, and "london" is only in the 'title' and 'bfd_places_city' fields of the 'places' template. They only meet in the 'event' template when their 'id' matches. A basic relational database situation I would say....

In a relational database the 'event' would be a calculation field, with values calculated 'on demand' only, but still searchable. I wonder if this is possible in ProcessWire.

Share this post


Link to post
Share on other sites

Example: http://www.birthfact...arch/?q=ballard returns only one page, from the category 'people'.

However, in the category 'Events' there are three pages that also refer to 'ballard' (they are listed as related events on the individual 'people' pages).

You are performing a text query, and that is only going to match the pages that contain that text in the field you are searching. it sounds like you want it to pull other pages that don't contain the text, but that are somehow related to the ballard page? In that case, you probably want to take the page result matching your text query (the one from the people category) and then, with that in hand, find the related event pages. I'm assuming you are using page reference fields for all of this stuff. Lets say your event template contains a field called "people" that references the people related to the event. Since your search results page has the person, but not the events, you could find the events like this:

// find any page referencing this person
// $page is the 'person' Page
$related = $pages->find("people=$page, sort=title"); 

// or find just events referencing this person
$events = $pages->find("people=$page, template=event, sort=-date");  

Share this post


Link to post
Share on other sites

I have that working fine for 'related events' on the individual 'people' and 'places' pages. Thank you.

What I was actually referring to is the search box. If you enter 'ballard' in the search box it only returns the 'people' page for ballard, not the events pages related to ballard.

On the 'events' page the names are called from the 'people' page by referring id.

$namepage = $pages->get("template=bfd_people, id=$page->bfd_events_people_id_list");

Would a Concat field offer some kind of solution? But I guess you can't do that with fields from one template on another.

Share this post


Link to post
Share on other sites

Another question about the standard ProcessWire search page. Is it possible to make a search for 'sara' and get results for 'sara' but also 'sarah'?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.