Coding Links in Pages

From TNG_Wiki
Jump to: navigation, search
Ambox notice.png The Coding Links in Pages provides examples of how to code links in pages in HTML or within a PHP section.

Request raised on the TNG Forum

But what I would now like to do is for say Feature 1. Is to have about 3 or 4 pages in total or perhaps more. With the word Next and Previous at the bottom of the page , so I could click between each page.


At the bottom of your feature1.php page, you could add the link as follows:

  • if not within a <?php ?> section as straight html
<a href="feature1_page2.php">Next</a>
  • if within the <?php ?> section as an echo statement
echo "<a href=\"feature1_page2.php\">Next</a> \n";

Note that you can end the php code section by adding a ?> before the straight html code and then restart it with a <?php after the html line.

At the bottom of youe feature1_page2.php, you could add the lins as follows:

  • if not within a <?php ?> section as straight html
<a href="feature1.php">Previous</a>  &nbspp;
<a href="feature1_page3.php">Next</a>
  • if within the <?php ?> section as an echo statement
echo "<a href=\"feature1.php\">Previous</a>  &nbspp;<a href=\"feature1_page3.php\">Next</a>\n";

You would then repeat something similar for your page 3, 4, and so on.

Note that quotes within an echo statement must be escaped with a backslash.

If you were supporting multiple languages the Previous and Next would be best handled with $text[previous] and $text[next] so they could be saved in your language cust_text.php with the correct translations.

Using buttons

If you would like to use buttons instead of links, you could use something like:

<input type="button" value="Previous" onclick="document.location='feature1_page1.php'"> 
<input type="button" value="Next" onclick="document.location='feature1_page3.php'">

Links to Person pages

If you want to make a link from the Feature Page to the Individual Person, you would code the link as follows:

<a href="<?php echo $cms['tngpath']; ?>getperson.php?personID=Innn&amp;tree=treeID">Person Name</a>

where personID=Innn identifies the person by its TNG personID which is I plus a number and tree=treeID identifies the ID assigned to your tree. You should be able to determine this by looking an Individual page displayed by TNG.

Related Links