Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Get the latest variable from Pods URL
- // $id = pods_url_variable('last');
- // Define the params to find the Pods Item based on the $id
- // $params = array( 'where' => 'permalink = "'.$id.'"' );
- // Display it by using Pods Template
- //echo pods( 'dragons' )->find( $params )->template( 'dragon_detail' );
- // Trying to include template in page.
- // Get the latest variable from Pods URL
- $id = pods_url_variable('last');
- $dragondata = new Pod('dragons', $id);
- // Getting variables
- $dragon_code = $dragondata->get_field('code');
- $dragon_name = $dragondata->get_field('name');
- $dragon_breed = $dragondata->get_field('breed');
- $dragon_gender = $dragondata->get_field('gender');
- $dragon_coga = $dragondata->get_field('coga');
- $dragon_pol = $dragondata->get_field('part_of_a_lineage');
- $dragon_lineage = $dragondata->get_field('lineage');
- $dragon_generation = $dragondata->get_field('generation');
- $dragon_mother = $dragondata->get_field('mother.id');
- $dragon_father = $dragondata->get_field('father.id');
- $dragon_armypart = $dragondata->get_field('part_of_an_army');
- $dragon_army = $dragondata->get_field('army.id');
- $dragon_partnerava = $dragondata->get_field('partner_available');
- $dragon_partner = $dragondata->get_field('partner.id');
- $dragon_partref = $dragondata->get_field('any_refusals');
- $dragon_refpart = $dragondata->get_field('refused_partner.id');
- $dragon_children = $dragondata->get_field('children');
- $dragon_childwho = $dragondata->get_field('existing_children.id');
- $dragon_gifted = $dragondata->get_field('gifted');
- $dragon_gifter = $dragondata->get_field('gifter');
- $dragon_giftnotes = $dragondata->get_field('gift_notes');
- $dragon_morenotes = $dragondata->get_field('other_notes');
- $dragon_url = $dragondata->get_field('permalink');
- // Pick the chosen value out of the array - needed for if statements.
- $dragon_coga2 = $dragondata->get_field('coga.id');
- $dragon_generation2 = $dragondata->get_field('generation.id');
- $dragon_mother_info = new Pod('dragons', $dragon_mother);
- $dragon_mother_url = $dragon_mother_info->get_field('permalink');
- $base_dragons_url = "http://dragoncreatures.com/dragons";
- $dragon_father_info = new Pod('dragons', $dragon_father);
- $dragon_father_url = $dragon_father_info->get_field('permalink');
- // Getting partner data
- $dragon_partner_info = new Pod('dragons', $dragon_partner);
- $dragon_partner_name = $dragon_partner_info->get_field('name');
- $dragon_partner_url = $dragon_partner_info->get_field('permalink');
- $partnerpod = new Pod('dragons', $dragon_partner);
- // get an array of the values, even if there's only one
- $partnerdata = (array) $partnerpod->field('partner.name.id');
- // get an array of the value field arrays, even if there's only one field array
- $partnerdata1 = (array) $partnerpod->get_field('partner.id');
- ?>
- <table>
- <TR>
- <TD>Dragon picture:<BR>
- <img src="http://dragcave.net/image/<?php echo $dragon_code; ?>.gif" style="border-width: 0" alt="Adopt one today!"/><BR>
- </TD>
- <TR>
- <TD>Dragon code: <?php echo $dragon_code; ?><BR>
- Dragon Name: <?php echo $dragon_name; ?><BR>
- Dragon breed: <?php echo $dragondata->display( 'breed' ); ?><BR>
- Dragon Gender: <?php echo $dragondata->display( 'gender' ); ?><BR>
- Dragon Coga: <?php echo $dragondata->display( 'coga' ); ?><BR>
- Dragon Coga version 2: <?php echo $dragon_coga2; ?><BR>
- Dragon Coga version 3: <?php echo $dragondata->display( 'coga.name' ); ?><BR>
- Dragon Part of a lineage: <?php echo $dragondata->display( 'part_of_a_lineage' ); ?><BR>
- Dragon lineage: <?php echo $dragondata->display( 'lineage' ); ?><BR>
- Dragon Generation: <?php echo $dragondata->display( 'generation' ); ?><BR>
- Dragon Generation version 2: <?php echo $dragon_generation2; ?><BR>
- Dragon mother: <?php echo $dragondata->display( 'mother' ); ?><BR>
- Dragon father: <?php echo $dragondata->display( 'father' ); ?><BR>
- Dragon part of an army: <?php echo $dragon_armypart; ?><BR>
- Dragon part of an army version 2: <?php echo $dragondata->display( 'part_of_an_army' ); ?><BR>
- Dragon Army: <?php echo $dragondata->display( 'army' ); ?><BR>
- Dragon Partner available: <?php echo $dragon_partnerava; ?><BR>
- Dragon Partner available: <?php echo $dragondata->display( 'partner_available' ); ?><BR>
- Dragon Partner: <?php echo $dragondata->display( 'partner' ); ?><BR>
- Dragon any refused partners?: <?php echo $dragondata->display( 'any_refusals' ); ?><BR>
- Dragon any refused partners version 2?: <?php echo $dragon_partref; ?><BR>
- Dragon Refused partners: <?php echo $dragondata->display( 'refused_partner' ); ?><BR>
- Dragon are there any children?: <?php echo $dragondata->display( 'children' ); ?><BR>
- Dragon Are there any children version 2?: <?php echo $dragon_children; ?><BR>
- Dragon who are the children?: <?php echo $dragondata->display( 'existing_children' ); ?><BR>
- Dragon did you get the dragon as a gift?: <?php echo $dragondata->display( 'gifted' ); ?><BR>
- Dragon Who gifted you the dragon?: <?php echo $dragondata->display( 'gifter' ); ?><BR>
- Dragon Any notes about the gift?: <?php echo $dragon_giftnotes; ?><BR>
- Dragon Any notes about the gift?: <?php echo $dragon_morenotes; ?><BR>
- </TD>
- </TR>
- </table>
- <p> </p>
- <table>
- <tr>
- <td>
- <b>now testing to see if statements will work properly.</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>First test, check which coga and display appropriate text based on coga.</u><BR>
- <?php
- if ($dragon_coga2 == 1)
- {
- echo "I caught this dragon in the cave.<BR>";
- }
- else
- if ($dragon_coga2 == 2)
- {
- echo "This is a dragon of my own breed.<BR>";
- }
- else
- if ($dragon_coga2 == 3)
- {
- echo "I got this dragon as a gift.<BR>";
- }
- else
- if ($dragon_coga2 == 4)
- {
- echo "I got this dragon from the Abandoned Area.<BR>";
- }
- else
- {
- echo "Something went wrong, because it is unclear where this dragon came from.<BR>";
- }
- ?><B>Test has succeeded.</B><BR>
- </td>
- </tr>
- <tr>
- <td>
- <u>Next test: Let's see if we can test if the dragon is part of a lineage.</u><BR>
- <?php
- if ($dragon_pol == 0)
- {
- echo "This dragon is not part of any lineage.<BR>";
- }
- else
- if ($dragon_pol == 1)
- {
- echo "This dragon is part a lineage.<BR>";
- }
- else
- {
- echo "Something went wrong, because it is unclear if this dragon is part of any lineage.<BR>";
- }
- ?><b>Test has succeeded.</b>
- </td>
- </tr>
- <tr>
- <td><u>Let's see if we can display the lineage after we've tested if the dragon is part of a lineage.</u><br>
- <?php
- if ($dragon_pol == 1)
- {
- echo "This dragon is part of the ";
- echo $dragondata->display( 'lineage' );
- echo " lineage.<BR>";
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon is not part of any lineage.
- }
- ?><b>test has succeeded</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>Now let's test if we can display the generation together with the lineage once a dragon is part of a lineage.</u><br>
- <?php
- if ($dragon_pol == 1)
- {
- echo "This dragon is part of ";
- echo $dragondata->display( 'generation' );
- echo " of the ";
- echo $dragondata->display( 'lineage' );
- echo " lineage.<BR>";
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon is not part of any lineage.
- }
- ?><b>test has succeeded.</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>Let's see if can adjust the generation terms. I want to display:</u><BR>
- <i>"This dragon is part of the first generation of the Seasonal dreams lineage."</i><BR>
- <?php
- if ($dragon_pol == 1)
- {
- if ($dragon_generation2 == 1)
- {
- echo "This dragon is part of first generation of the ";
- echo $dragondata->display( 'lineage' );
- echo " lineage.<BR>";
- }
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon is not part of any lineage.
- }
- ?><b>test has succeeded.</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>Let's test if the dragon has a mother and if so, who this mother is.</u><BR>
- <?php
- if ($dragon_mother != '')
- {
- echo $dragondata->display( 'mother' );
- echo " is ";
- echo $dragon_name;
- echo " 's mother<BR>";
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon has no mother.
- }
- ?><b>test has succeeded.</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>Now let's see if we can have a link with the mother's name.</u><BR>
- <?php
- if ($dragon_mother != '')
- {
- echo "<a href=\"$base_dragons_url/$dragon_mother_url\">";
- echo $dragondata->display( 'mother' );
- echo "</a>";
- echo " is ";
- echo $dragon_name;
- echo " 's mother<BR>";
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon has no mother.
- }
- ?> <b>Test has succeeded</b> </td>
- </tr>
- <tr>
- <td>
- <u>Let's test if the dragon has a father and if so, who the father is.</u><BR>
- <?php
- if ($dragon_father != '')
- {
- echo $dragondata->display( 'father' );
- echo " is ";
- echo $dragon_name;
- echo " 's father<BR>";
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon has no father.
- }
- ?><b>Test has succeeded</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>Now let's see if we can have a link with the father's name.</u><BR>
- <?php
- if ($dragon_father != '')
- {
- echo "<a href=\"$base_dragons_url/$dragon_father_url\">";
- echo $dragondata->display( 'father' );
- echo "</a>";
- echo " is ";
- echo $dragon_name;
- echo " 's father<BR>";
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon has no father.
- }
- ?> <b>Test succeeded. Onto the next one.</b> </td>
- </tr>
- <tr>
- <td>
- <u>Next test: Let's see if we can test if the dragon is part of an army.</u><BR>
- <?php
- if ($dragon_armypart == 0)
- {
- echo "This dragon is not part of any army.<BR>";
- }
- else
- if ($dragon_armypart == 1)
- {
- echo "This dragon is part an army.<BR>";
- }
- else
- {
- echo "Something went wrong, because it is unclear if this dragon is part of any army.<BR>";
- }
- ?><b>Test has succeeded</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>Next test: Let's see if we can test if the dragon is part of an army AND if so, of which army the dragon is a part of.</u><BR>
- <?php
- if ($dragon_armypart == 0)
- {
- echo "This dragon is not part of any army.<BR>";
- }
- else
- if ($dragon_armypart == 1)
- {
- echo "This dragon is part of ";
- echo $dragondata->display( 'army' );
- echo "<br>";
- }
- else
- {
- echo "Something went wrong, because it is unclear if this dragon is part of any army.<BR>";
- }
- ?><b>Test has succeeded</b>
- </td>
- </tr>
- <tr>
- <td>
- <u>Let's test if the dragon has a partner</u><BR>
- <?php
- if ($dragon_partnerava == 0)
- {
- echo "This dragon does not have a partner.<BR>";
- }
- else
- if ($dragon_partnerava == 1)
- {
- echo "This dragon has a partner.<BR>";
- }
- else
- {
- echo "Something went wrong, because it is unclear if this dragon has a partner.<BR>";
- }
- ?><b>Test has succeeded</b>
- </td>
- </tr>
- <tr>
- <td><u>Let's see if we can display the partner after we've tested if the dragon has a partner.</u><br>
- <?php
- if ($dragon_partnerava == 1)
- {
- echo $dragon_name;
- echo " has ";
- echo $dragondata->display( 'partner' );
- echo " as a partner.<BR>";
- }
- else
- {
- echo ""; //We don't need to display anything if the dragon is not part of any lineage.
- }
- ?><b>Test has succeeded</b>
- </td>
- </tr>
- <tr>
- <td><u>Let's see if we can have a link with the partner's name</u><br>
- <?php
- if ($dragon_partner != '')
- {
- echo $dragon_name;
- echo " has ";
- echo "<a href=\"$base_dragons_url/$dragon_partner_url\">";
- echo $dragondata->display( 'partner' );
- echo "</a>";
- echo " as a partner.<BR>";
- }
- else
- {
- echo "this dragon has no partner"; //We don't need to display anything if the dragon has no partner.
- }
- ?>
- <b><font color="red">This displays the wrong link. Let's try this with Foreach instead.</font></b>
- </td>
- </tr>
- <tr>
- <td><u>A test to see how $key and $value are determined</u><br>
- <?php
- $fruit = array(
- 'orange' => '5.00',
- 'apple' => '2.50',
- 'banana' => '3.99'
- );
- foreach ($fruit as $key => $value) {
- echo "$key is $value dollars <br>";
- }
- ?>
- Test is ongoing
- </td>
- </tr>
- <tr>
- <td><u>Let's see if we can get the partner names with the adjusted name</u><br>
- <?php
- if ($dragon_partner != '')
- {
- echo $dragon_name;
- echo " has ";
- echo "<a href=\"$base_dragons_url/$dragon_partner_url\">";
- echo $dragon_partner_name;
- echo "</a>";
- echo " as a partner.<BR>";
- }
- else
- {
- echo "this dragon has no partner"; //We don't need to display anything if the dragon has no partner.
- }
- ?>
- <B><font xolor="red">De verkeerde naam wordt gepakt als er meer dan 1 dragon als partner is. Nu eerst uitzoeken hoe ik de juiste data uit de array kan pakken.</font></B>
- </td>
- </tr>
- <tr>
- <td><u>First, let's get the partner (names) from the partner array instead of the $dragondata </u><br>
- <?php
- if ($dragon_partner != '')
- {
- echo $dragon_name;
- echo " has ";
- echo $partnerdata;
- echo "</a>";
- echo " as a partner.<BR>";
- }
- else
- {
- echo "this dragon has no partner"; //We don't need to display anything if the dragon has no partner.
- }
- ?>
- Test is ongoing
- </td>
- </tr>
- <tr>
- <td><u>wederom nieuwe poging: get an array of the value field arrays, even if there's only one field array</u><br>
- <?php
- if (isset($partnerdata1['partner.id']))
- {
- $partnerdata1 = array( $partnerdata1 );
- echo $dragon_name;
- }
- // echo " has ";
- // echo $partnerdata;
- // echo "</a>";
- // echo " as a partner.<BR>";
- else
- {
- echo "this dragon has no partner"; //We don't need to display anything if the dragon has no partner.
- }
- ?>
- Test fails. Nieuwe poging met iets anders.
- </td>
- </tr>
- <tr>
- <td><U>nieuwe poging: let's display the content of the array and then echo the values and keys.</U><BR>
- <?php
- if ($dragon_partner != '')
- {
- var_dump($dragon_partner);
- echo "<BR>";
- foreach ($dragon_partner as $key => $value)
- {
- echo 'Key: ' . $key . ' Value: ' . $value . "<BR>";
- }
- }
- ?>
- </td>
- </tr>
- <tr>
- <td><U>Now let's see if we can get the names from the partners</U><BR>
- <?php
- if ($dragon_partner != '')
- {
- var_dump($dragon_partner);
- echo "<BR>";
- foreach ($dragon_partner as $key => $value)
- {
- $partnerinfo = array( 'where' => 'id = "'.$value.'"' );
- $partnerinfopod = pods( 'dragons', $partnerinfo );
- $partnername = $partnerinfopod->get_field('name');
- while ( $partnerinfopod->fetch() )
- {
- echo $partnername;
- echo "something was processed<BR>";
- }
- }
- }
- ?>
- </td>
- </tr>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement