SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2012
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cool Parent/Child Database/Included Data Question

    This is probably a stupid question, because it seems like the solution should be obvious, but here goes...

    I have a database that lists animal taxons in a parent-child relationship, something like this...

    TAXON | RANK | PARENT
    Animalia | kingdom | (NULL)
    Chordata | phylum | Animalia
    Mammalia | class | Carnivora
    Carnivora | order | Mammalia
    Felidae | family | Carnivora
    Panthera_leo | species | Felidae

    In other words, Panthera leo (the lion) is a member of the cat family (Felidae), which is a child of the order Carnivora, etc.

    It's apparently working, because it displays bread crumb navigation links. For example, the following links appear at the top of the Panthera leo (lion) page:

    Life > Animala > Chordata > Vertebrata > Mammalia > Carnivora > Felidae > Panthera > Panthera leo

    So far so good, but I'm not sure how to implement the next step.

    I want to create a mountain of content - in a database and/or PHP includes - that will be displayed on pages based on taxonomy. Let's take legs, for example. I start by creating the following rules:

    Mammals - all have 4 legs, except...
    > bats (2 legs)
    > marine mammals (0 legs)

    Birds - all have 2 legs

    Reptiles - all have 4 legs, except...
    > worm lizards, 0 legs, except...
    >> members of the genus Sphinux (2 legs)
    > snakes (0 legs)

    Fish - all have 0 legs

    It probably doesn't matter if I have this information stored in a database or a PHP switch. But the next step is to display it on the proper pages. So if I navigate to the URL Life/Canis_lupus (wolf), the text would read "This animal has four legs."

    If I navigate to Life/Blue_Whale, the text would read "This animal has 0 legs" (Or "This animal has a pair of flippers instead of legs."

    * * * * *

    Since I already have bread crumb navigation links, it should be simple, but I can't get my mind wrapped around it. I think the first step is to give each dynamic page a taxonomic identity - on multiple levels. For example, if I navigate to Life/Canis_lupus (wolf), then that page should say, "I'm a wolf, my parent is parent (family) is Canidae, my grandparent (order) is Carnivora and my grand grandparent (class) is Mammalia."

    That way, if I have some content that says "All mammals (Mammalia) have fur," that will automatically be displayed on pages that recognize themselves as mammals. And if I have a PHP switch that says any mammal belonging to the order Carnivora should include the text "I have sharp canines," that text will also appear on the wolf page - but not the rabbit page.

    Sorry for the long explanation, and I may have to post some of my code before anyone can help me, but one step at a time. Does my explanation make sense? If so, can you suggest the next step?

    Since I already have bread crumb navigation links, I'm guessing every page already "recognizes" itself - am I right? I think this will be an easy task once I figure out a few basics.

    Thanks!

  2. #2
    SitePoint Addict
    Join Date
    Jan 2012
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    P.S. Perhaps a simpler approach would be ask how I can create a script that will display a page's family. If it says "My family = Felidae," then it should display the appropriate script from a PHP switch...

    Code:
    switch($Family)
    {
     case 'Felidae':
     echo 'Cats have sharp claws.';
     break;
     case 'Ursidae':
     echo 'Bears hibernate in winter.';
     break;
     default:
     break;
    }
    I could then do the same thing with other taxonomic ranks - order class, etc.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •