Jump to content

Search question


BFD Calendar
 Share

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.)

Link to comment
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.

Link to comment
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");  
Link to comment
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.

Link to comment
Share on other sites

  • 4 years later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...