Jump to content

PageField and Pedigrees...


Ralf
 Share

Recommended Posts

Hi

today I have sure a simple question for the expert audience. My actual Project with PW is build up a Homepage for a horse breeding farm and the point I come across are the pedigrees from the horses (more than 100...).

For example it looks like that:



Father - paternal grandfather - great-grandfather
                              - great-grandmother
       - paternal grandmother - great-grandfather
                              - great-grandmother

Mother - maternal grandfather - great-grandfather
                              - great-grandmother
       - maternal grandmother - great-grandfather
                              - great-grandmother


The question which goes through my head since a couple of days, how I make the pedigree - from each horse - as easy to complete as possible?

I thought of "Page Fields" for each horse (Title and title_value) which is filled via an autocomplete when writing. And at the first time a data import with csv, i hope that would be easy ...

BUT how do I implement it now, that when i have the parents, grandparents or great-parents in my breeding stock - and they have a own Page (with also a pedigree, the name, some pictures, a description, ...) that on my database there is a LINK to this Page and not only a Name??

How would you solve that?

a) With two query fields for the user number one he should use when he want to link to another side and number two when he want only type in the name?

b) for each horse the same "full page" and in the query, only one field is to link ready or not (depending on whether the page has been filled or not?)

c) something else?

Oh one thing more, the main categories under Home are (if this is relevant):



-Home
-- Stallions
---- Stallion 1
---- Stallion 2
...

-- Broodmare
---- Broodmare 1
---- Broodmare 2
...

-- Colt
---- Colt 1
---- Colt 2
---- Colt 3
...


I am grateful for any idea

cu Ralf

Link to comment
Share on other sites

On a template named 'horse' add two fields with the type of Page. (both Single page)

Name one field 'father' and the other 'mother'. (  Allow new pages to be created from field?, Set to yes )

I advice you you use Page autocomplete (not installed by default) as horse lovers know all the horses by name :-)

Make both fields required (force the editor to fill it in), but then you have to create one "Null Horse". 

the selectable parent of the 'horse' is always 'horses', 

The Null Horse is a Page with template horse and it's not an existing horse. When they don't know their parent(s) they can select the Null horse.

When the Null horse is reached it's end of the tree.



// Structure for horses, all on the same level

home
|
+-- horses (horses template)
\
+-- abram (horse template)
|
+-- betty (horse template)
|
+-- cinderella (horse template)
|
+-- dromedary
|
+-- etc..

  • Like 4
Link to comment
Share on other sites

@ kongondo

thanks for your link - I have read the article twice already, but not sure if i found the right "Categorie"...

I think its  1. Single Category

Categories = Departments = Stallion/ Broodmare/ Colt

Items of interest = Employees = the horse

...I will read it again ;)

> Btw, how deep will the ancestry go?

The Example in my first Post is the "final" deep!! I´m not sure if this is an international standard but in Europe it is so. We have thus all in all 4 Generations.

@ Martijn

thanks for your reply but it could be that i´m not clarify enough in my first post or I have completely misunderstood your contribution. ALL horse names are clear and they/we knew the parents.

I thought I could solve this so:

I have 14x Fields with "Page autocomplete" for the pedigree in my template in the backend (ok a little bit more Fields  for example for a Description, the name of the horse, some pictures, ....). Every Field uses the Page autocomplete so that the fill in process needs only a few seconds per horse.

BUT the problem now - for me - is that when a horse from the pedigree already has its own page on the website I do not want only the name of the horse in the current pedigree, I also want a link to the appropriate page (the mother, father,. ...).

This is my proper Question, how can i solve this issue? Should i use 28x Fields in the template - for each horse a Page autocomplete Field only for a "text" Name and one Field for a Name with a Link to another Side??? Or did you have a completely different method?

Thanks Ralf

Link to comment
Share on other sites

This man Martijn is a clever man.....Let me attempt to expound on what he has said......Warning verbosity!!

You do not need those 14 fields (to cover both maternal and paternal roots - 7 each). Consider this as an family tree. If you follow a branch, it will lead you to other branches, etc. In ProcessWire, there is something called chaining....Let's say you have a horse called "Midnight Run". You only need to know the parents to make a complete tree. Why? Because, in the parents pages, they will also have Page Fields which will contain their parents. So, "Midnight Run" has a mother called "Fairy Tale" and a father called "Nostalgia". Both "Fairy Tale"and "Nostalgia" have their own pages. In their respective pages, their parents are selected (via page fields). For "Fairy Tale" let's call them (her parents)  "Lucky Luke"  (father) and "Angel" (mother). For "Nostalgia", the father is "Big Grey" and the mother is "Seasons"....and so on it goes...."Big Grey", "Seasons", "Lucky Luke" and "Angel" also have page fields with parents selected, etc. Up to the 4th generation.

So....

  • Like 2
Link to comment
Share on other sites

ALL horse names are clear and they/we knew the parents.

You'll end up to a parent where you don't know their parent. Evolution is a long long long process....  ;)

In the pedigree it would be nice that you can click all horses in that tree. And each horse have it's own pedigree. 

I do advise you to stop the Pedigree loop till x depth of parents reached.

Link to comment
Share on other sites

Building up on above....even more verbosity...!!! (last one, I promise!! - I got carried away :-))
 
We have single page select fields for each horse, i.e. "mother" and "father". And here we go...We let PW do all the donkey work (excuse the pun!)....PW will find the titles of this page's page fields and the titles of the page fields of those other page fields, etc, etc...

echo '<h5>First Generation</h5>';
echo 'My name is: <strong>' . $page->title . '</strong><br>';
echo '<hr>';

echo '<h5>Second Generation</h5>';	
echo 'My Mother is: <strong>' . $page->mother->title . '</strong><br>';
echo 'My Father is: <strong>' . $page->father->title . '</strong><br>';

echo '<hr>';

echo '<h5>Third Generation</h5>';
echo '<h6>Maternal</h6>';
echo 'My Maternal Grandmother (mother-mother) is: <strong>' . $page->mother->mother->title . '</strong><br>';
echo 'My Maternal Grandfather (mother-father) is: <strong>' . $page->mother->father->title . '</strong><br>';

echo '<h6>Paternal</h6>';
echo 'My Paternal Grandmother (father-mother) is: <strong>' . $page->father->mother->title . '</strong><br>';
echo 'My Paternal Grandfather (father-father) is: <strong>' . $page->father->father->title . '</strong><br>';

echo '<hr>';

echo '<h5>Fourth Generation</h5>';

echo '<h6>Maternal</h6>';
echo 'My Maternal Great Grandmother (mother-father-father) is: <strong>' . $page->mother->father->father->title . '</strong><br>';
echo 'My Maternal Great Grandfather (mother-father-mother) is: <strong>' . $page->mother->father->mother->title . '</strong><br>';
echo 'My Maternal Great Grandmother (mother-mother-father) is: <strong>' . $page->mother->mother->father->title . '</strong><br>';
echo 'My Maternal Great Grandfather (mother-mother-mother) is: <strong>' . $page->mother->mother->mother->title . '</strong><br>';

echo '<h6>Paternal</h6>';
echo 'My Paternal Great Grandmother (father-mother-father) is: <strong>' . $page->father->mother->father->title . '</strong><br>';
echo 'My Paternal Great Grandmother (father-mother-mother) is: <strong>' . $page->father->mother->mother->title . '</strong><br>';
echo 'My Paternal Great Grandfather (father-father-father) is: <strong>' . $page->father->father->father->title . '</strong><br>';
echo 'My Paternal Great Grandfather (father-father-mother) is: <strong>' . $page->father->father->mother->title . '</strong><br>';

The above will give you something like this...

Midnight Run

1. First Generation
My name is: Midnight Run

2. Second Generation
My Mother is: Fairy Tale
My Father is: Nostalgia

3. Third Generation
 
Maternal
My Maternal Grandmother (mother-mother) is: Angel
My Maternal Grandfather (mother-father) is: Lucky Luke

Paternal
My Paternal Grandmother (father-mother) is: Seasons
My Paternal Grandfather (father-father) is: Big Grey
 
4. Fourth Generation
 
Maternal
My Maternal Great Grandfather (mother-father-father) is: Bonnie
My Maternal Great Grandmother (mother-father-mother) is: Blue
My Maternal Great Grandfather (mother-mother-father) is: Breeze
My Maternal Great Grandmother (mother-mother-mother) is: Dancer

Paternal
My Paternal Great Grandfather (father-mother-father) is: Stop That Train
My Paternal Great Grandmother (father-mother-mother) is: Puzzle 
My Paternal Great Grandfather (father-father-father) is: Xmen
My Paternal Great Grandmother (father-father-mother) is: Rosie
  • Like 2
Link to comment
Share on other sites

By the way, if you have too many horses to choose from in the page fields (and also to minimize mistakes), you can instead have two templates for the horses: "male-horses" and "female-horses". Then force the page fields "father" and "mother" "Template of selectable pages" to use these templates respectively.. This also helps if you want to output say, only the male horses, etc...You get the idea :-)

  • Like 2
Link to comment
Share on other sites

@ kongondo

:rolleyes: you are tooo fast for me... i prepared a answer but without reading your last two comments (awesome) but I'll make up for it immediately

Here is my answer to the other comments...

Sorry sorry sorry guys, I don´t get it :-[

You only need to know the parents to make a complete tree. Why? Because, in the parents pages, they will also have Page Fields which will contain their parents.

Yes and No ... In my scenario I don´t have for all Parents in the tree own pages!! Why? equal to more

In the pedigree it would be nice that you can click all horses in that tree.

I think this is the problem why i don´t understood your answer, it is not the intention that ALL HORSES are CLICKABLE!!! only that horses that have a own page at the homepage (and thats less than 10% over the complete homepage from the horses in the pedigrees).

Would it be helpfull if you could see the acutal homepage? I think so...
 

Here is for example one page of a Colt
http://www.trakehnerhof-st-vitus.de/home/fohlen/lessing-v.-lossow-u.d.-prst-linn-v.-eh-friedensfürst

As you can see the pedigree is only a part of the page for a horse (here: "Lessing"). But in the pedigree i have parents with a own page ("Lossow" and "PrSt Linn") but not for the other because they don´t have a own page and so i don´t want a clickable link/name.

And all that information for a horse page (Name, Birthday, Owner, Price, Description, some Pictures AND the pedigree) the user should fill in one template, that's the thought behind it.

OK that was the plan but now i read the new comments from kongondo...

Link to comment
Share on other sites

if you have too many horses to choose from in the page fields

Here's a lot of assumptions: 

I do think, that horses are born  :P , it has a born date.

The parent is always at least an x amount of time older that the recent horse.

It's good to have a radio option for the gender:

radio's (3 options, I think)

- Stalion

- Mare

- Ruin ( castrated )

So fo find a father:

It has to be NOT a Mare ( effectively it's a stalion or a ruin in his glory days :P  )

And it has to be X amount of time older then the Current horse

  • Like 1
Link to comment
Share on other sites

@Ralf. The main thing here is first to deal with the parentage issue. The rest - description, owner, price, birthday, etc. are simpler. They are just fields that you can have in the horses template. 

The pedigree can either be single page fields, or you can create your Page's Tree to reflect pedigree as you've shown in your first post.

Just to repeat, about clickable, like Martijn said, you can enable and disable that. 

So, in a nutshell - ALL horses must have a page in the backend (in your admin...i.e. as children of the page "horses" who is a child of "home") BUT not all of these horses pages' will be viewable in the frontend. For such, you will not output their links to the pages and if your web visitors try to enter the address to that non-clickable horse manually (phew! - that was long!) - they get a nice 404 page not found :-). if you don't know a horses parents, there's the Null Martijn suggested...

Edited by kongondo
  • Like 2
Link to comment
Share on other sites

You draw this: 

-Home
-- Stallions
---- Stallion 1
---- Stallion 2
...

-- Broodmare
---- Broodmare 1
---- Broodmare 2
...

-- Colt
---- Colt 1
---- Colt 2
---- Colt 3

I suggest:

Home
  |
  +-- Horses ( enable urlSegments )
      |
      +-- Name of the horse (add a Page field, [Stallions, Broodmare, Colt, etc..])
      +-- Other horse
      +-- And another horse
      +-- etc.

domain.de/horses/stallions/    -> stallions is a urlSegment, vallid segments are the ones from the Page field

  • Like 4
Link to comment
Share on other sites

@ Martijn

I´not sure but i think I understood :-)

Home
  |
  +-- Horses ( enable urlSegments )
      |
      +-- Name of the horse (Template "horse")
      +-- Other horse (Template "horse")
      +-- And another horse (Template "horse")
      +-- etc.

And this are the Fields in the Template "horse"?
- a Page field, [stallions, Broodmare, Colt, etc..]
- a Page field -> horse_father
- a Page field -> horse_mother
- a Checkbox -> enable or disable a link to this horse
- and each a Text/Textarea Field for description, owner, price, birthday, etc.

But the first Question it run through my head with this solution is that at the end of the day I have one categorie "horses" with I don´t know 500+ Pages. How can the prospective editor quarrels this mass and taking care not to lose the overview?

In my first thoughts I handle this with 4 Categories (Stallion/Broodmare/Colt and a hidden "selects_for_pedigree").

Now I understood the Power from your solution and ask me is there a way to handle it with 2 Categories ????
- One for the OWN_horses (Categorie "Horses" from above - with all horses that have a fullfilled Page OR Checkbox = enabled) and
- One for the selectable_for_pedigree horses (with also the template=horse but the checkbox = disabled and nothing else in it as the title)

The benefit should be a small (~100), manageable number of pages in Categorie 1 (where the editors are weekly) and 400-500+ Pages in the other categorie which is only used for the pedigree.

Some additional Questions:
a) Is there a possibility that in the backend search (for the fields "Mother" and "Father") to carry out not only one category but over two or more categories?
Could I do that with for example the Template?

b) When later a new horse born, the mother-tree is clear I have it on the site but how is the "right way" to capture the Pedigree Data for the father-tree (when the horses not yet in PW)??
1) New Page - paternal grandfather (with the name of his parents)
2) New Page - paternal grandmother (with the name of her parents)
3) New Page - Father (with the autocompletion function for his parents because Step 1 and 2)
4) New Page - new born horse ....
=> Result 4 Steps for 1 new horse

OR is there a way in PWs Backend that this 4 Steps can be done in 1??

Again big thanks to Martijn and kongondo!!!

  • Like 1
Link to comment
Share on other sites

But the first Question it run through my head with this solution is that at the end of the day I have one categorie "horses" with I don´t know 500+Pages. How can the prospective editor quarrels this mass and taking care not to lose the overview?

500 horses is a lot, but consider that the editor know the horse by name and the search in ProcessWire is great.

If the whole setup is complete consider a simple ProcessModule that lists not-yet-editted horses. 

b) When later a new horse born, the mother-tree is clear I have it on the site but how is the "right way" to capture the Pedigree Data for the father-tree (when the horses not yet in PW)??

set the "Allow to create a new page" to the page field. (father) 

It's likely that for the breeding program, some stallions are real lucky they have a lot of offspring, while others (example sport horses) have no offspring.

Link to comment
Share on other sites

Hi @all

After I adopted Martijn suggestion, i have a new Question about the Navigation.

The actual situation is now, that the Front-End Navigation from the new site should look like that:

Home
 |
 +-- Our Horses
 |    |
 |    +-- Stallions
 |    |
 |    +-- Broodmare
 |    |
 |    +-- Colt
 |
 +-- Horses for sale
     |
     +-- Riding Horses
     |
     +-- Broodmare
     |
     +-- Foals and young horses

And that all combined with a breadcrumb :/

How would you solve that?

With the tip from URLSegments i thought, one option could be "checkboxes" for all 6 Options/Sites from above and the "User/Editor" can select one OR more Sites on which the actual horse will be presented on the Homepage.
But how do I use it for building my navigation let alone a breadcrumb?

Questions about questions...

Did somebody have any answers ???

Link to comment
Share on other sites

Create this structure: [ later on used for the Inputfield type Page (Multiple) ] 
Home
 |
 +-- Types (template: types)
     |
     +-- Stallions      (template name: type)
     |
     +-- Broodmare      (template name: type)
     |
     +-- Colt           (template name: type)
     |
     +-- Foals & youngs (template name: type)
     |
     +-- etc.

// both templates need no template files

To the template 'type' you add a textarea with a WYSIWYG editor if wished.

 

On the Horse Template
1 ) a checkbox, named: horse_owned, 
2 ) a checkbox, named: for_sale, 
3 ) an Inputfield type Page, see structure above name the field 'types'
 

Group template ( Our Horses & Horses for sale )
 
Assign the same fields as above to this page.
1 ) a checkbox, named: horse_owned, 
2 ) a checkbox, named: for_sale, 
3 ) an Inputfield type Page, with the structure drawn above ( Name it types  )
 
The real purpose of these fields in the 'group' template are for building the search query to the horses you want to list. (Tell you later more about this)
Enable urlSegments to this template.
 
Create a Page with the group template named 'Our Horses'
Check the checkbox 'horse_owned', so it has the value of 1
Leave the checkbox 'for_sale' unchecked.
For the 'types' field select:
[x] Stallions
[x] Broodmare
[x] Colt
[ ] Riding Horses
[ ] Foals and young horses

Those checked pages are used for the urlSegments. Basic structure of the PHP file could look like this:

$segment = $input->urlSegment1;
$types = $page->types;

if ($input->urlSegment1) {

    $name = $sanitizer->name($input->urlSegment1);
    $type = $pages->get("template=type, name=$name");

    if ($types->has($type)) {
        echo "<h1>{$type->title}</h1>";
        // echo $type->body; // assumed the textarea added is called body
        
        // scaffold the search query
        $query = array(
            'template' => 'horse',
            'types' => $type,
            'horse_owned' => $page->horse_owned,
            'for_sale' => $page->for_sale,
            'limit' => 10
            );

        $query = array_filter($query); // remove all boolean false elements from array
        $string = '';
        foreach ($query as $key => $value) $string .= "{$key}={$value}, ";
        $string = rtrim($string, ", ");

        $horses = $pages->find($string);
        if(count($horses)) {
            echo "jay we have the horses";
        } else {
            echo "Sorry, at the moment we don't have the horse that you're lookin for."
        }
    
    } else {
        throw new Wire404Exception();
    }

} else {

    echo "<ul>";
    foreach ($types as $type) {
        echo "<li><a href='{$page->url}{$type->name}/'>$type->title</a></li>";
    }
    echo "<ul>";

}

(not fully tested, so could have a bug or 2 )

  • Like 5
Link to comment
Share on other sites

  • 2 weeks later...

Hi Martijn,

thanks a lot for your answer!!

Just a few Questions - sorry i´m a beginner :)

(not fully tested, so could have a bug or 2 )

You are right,

but this line:

echo "Sorry, at the moment we don't have the horse that you're lookin for."

needs only a ";" at the end...

But my bigger Question is ... understand i that correctly, that with this php-Code i can build a navigation??

I have at the moment a little problem, to understand the whole context. I hope the knot in my head dissolves soon... ;)

A second Question:

how should a template and/or a php file of 'horse' now look like??

Are this fields for the template correct?

For the Navigation

-  a checkbox, named: horse_owned, (see Martijns last post)

- a checkbox, named: for_sale, (see Martijns last post)
For the sex
- an Inputfield type Page, see structure above name the field 'types' (IS this Field for the Select "- a Page field, [stallions, Broodmare, Colt, etc..]" ???)
For the pedigree

- a Page field -> horse_father (with AutoComplete and new Sites/Horses will be created as subpages from Home->Horses)
- a Page field -> horse_mother (with AutoComplete and new Sites/Horses will be created as subpages from Home->Horses)
- a Checkbox -> horse_enable (for enable or disable a link to this horse)
All the rest of information

- and each a Text/Textarea Field for description, owner, price, birthday, etc.

Did i miss something??

Big Thanks for your great help!!

Ralf

@ Martijn

When this Homepage is online i think a big thanks to the community i can gave back is, that i want write a tutorial for this special requirement with all your helpful answers and suggestions!!

Link to comment
Share on other sites

I didn't post anything for the pedigree. The pedigree part can be done later on the horse template. Don't overcomplicate things, just build things from the bottom up. The part I posted goes till you have a list of horses. (Pagearray)

That array you can loop and link to the individual horse. ( So forget about the pedigree till the navigation structure is complete. )

These are in the group contexts just search filters:

- a checkbox, named: horse_owned, (horse template should also have horse_owned checkbox, checked means you're owning the horse )
- a checkbox, named: for_sale, (horse template should also have for_sale checkbox, checked means you're willing to sell the horse )
 
- an Inputfield type Page, see structure above name the field 'types' (IS this Field for the Select "- a Page field, [stallions, Broodmare, Colt, etc..]" ???)
Inputfield type Page in the horse template just to identify what horse type it is. But it the Group template it is used as a filter. (the code is fro the group template) Here you gonna test if the UrlSegments matches the checked horses in the group template. This way you can control which horses to list.
 
If your navigation setup is complete, I can help you to setup the pedigree function inside the horse template. I would advise you to leave it alone for now. 
  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

Ralf needed a parental Pedigree and I helped him to setup a very basic site. I quite liked the building of it and it resulted in doing 'to much' just for fun. I Asked Ralf if I could make it to a site profile so that someone else could profit from it to.

Horse template

post-577-0-16971500-1399572804_thumb.png

Family Tab (Horse template)

post-577-0-19541700-1399573160_thumb.png

Pedigree (d3js)

post-577-0-98536500-1399572806_thumb.png

Unfinished Horse ( Horses created by Pagefield, but not yet edited )

post-577-0-84212200-1399572810_thumb.png

Menu building /processwire

post-577-0-60802600-1399572805_thumb.png

Menu front-end

post-577-0-57936900-1399573032_thumb.png/

Download The Profile:

pedigree_profile.zip

  • Like 13
Link to comment
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
 Share

  • Recently Browsing   0 members

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