Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should create a PHP class and include it in your header, or make it your header. Invoke it on the page then assign the value for the class variable which you can then echo a separate class function which uses the variable values you require. I can provide an example if you're unfamiliar with the process.</p> <p><strong>Header.php simple example:</strong></p> <pre><code>&lt;?php class Template { private $active_nav; private __construct() { } public function set_active($page = '') // set page test value { $this-&gt;active_nav = $page; } public function get_active() // return page test value { return $this-&gt;active_nav; } public function nav_links() // this could be changed to return an entire header or part or whatever -- change the scope accordingly { // active link CSS is linSktyleOne $current_page = $this-&gt;get_active(); $nav_links = '&lt;ul&gt;'; $nav_links .= '&lt;li&gt;&lt;a href="index.php" class="' . ($current_page == 'index' ? "linkSytleOne" : "linkStyleTwo") . '"&gt;Index&lt;/a&gt;&lt;/li&gt;'; $nav_links .= '&lt;li&gt;&lt;a href="contact.php" class="' . ($current_page == 'contact' ? "linkSytleOne" : "linkStyleTwo") . '"&gt;Contact&lt;/a&gt;&lt;/li&gt;'; $nav_links .= '&lt;/ul&gt;'; return $nav_links; } } </code></pre> <p><strong>contact.php simple example:</strong></p> <pre><code>&lt;?php require_once('includes/header.php'); $template = new Template; $template-&gt;set_active('contact'); // put all your html or other code here echo $template-&gt;nav_links(); ?&gt; &lt;!-- blah blah code finished --&gt; &lt;? // you can always echo a footer out here through a function in the template as well </code></pre> <p><strong>index.php simple example:</strong></p> <pre><code>&lt;?php require_once('includes/header.php'); $template = new Template; $template-&gt;set_active('index'); // put all your html or other code here echo $template-&gt;nav_links(); ?&gt; &lt;!-- blah blah code finished --&gt; &lt;? // you can always echo a footer out here through a function in the template as well </code></pre> <p>Does all that help make more sense? You only add 1 line of code to each page, and if you really wanted to get fancy you could remove the set function invocation on each page by using a substring of the<code>$_SERVER['REQUEST_URI']</code> value for a conditional test and put the condition to set the value in the constructor of the class.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload