Example #1
0
 function test_slug_name()
 {
     $this->assertEqual(slug_name('Life with Braces®'), 'life-with-braces');
     $this->assertEqual(slug_name('TMJ/TMD'), 'tmj-tmd');
     $this->assertEqual(slug_name('In-Ovation®'), 'in-ovation');
     $this->assertEqual(slug_name('Damon™'), 'damon');
     $this->assertEqual(slug_name('Why Braces?'), 'why-braces');
     $this->assertEqual(slug_name('Braces 101'), 'braces-101');
     $this->assertEqual(slug_name('!!??$$Braces!!$$'), 'braces');
     $this->assertEqual(slug_name('!!?()?$$Braces!!$$'), 'braces');
 }
Example #2
0
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
	<title>Doozer PHP Navigation Framework</title>

	<script>
    $(document).ready(function(){
  		//$('li.first').append('<span class="quiet">  < first</span>');
  		//$('li.last').append('<span class="quiet">  < last</span>');
  		//$('#nav-with-sub a[href^="http://"]').after('<span class="quiet"> (external)</span>');
  		//$('a.head').after('<span class="quiet"> < head </span>');
  	});//end document.ready
  </script>

</head>

<body class="<?php 
echo slug_name($_name);
?>
">

<div class="container">

<h1>Doozer &ndash; A PHP Navigation Framework</h1>

<p>This is an example page illustrating the available PHP functions that utilize the site structure defined in <code>sitemap.php</code>.</p>

<p>By defining <code>$_page</code> and <code>$_section</code> variables for each page, we can call the following functions from each page and get dynamically generated navigation elements.</p>

<p>These functions are defined in <code>global.php</code>. To enable this functionality include <code>global.php</code> on every page before calling the header include. Then define the site structure as an array in <code>sitemap.php</code>, also kept in the includes folder. (<strong>Note:</strong> The root level &#8216;Site Map&#8217; page should be named <code>site-map.php</code> to avoid conflicting names.)</p>

<h2>Naming Conventions</h2>
Example #3
0
/**
 * Determines the link for the current section.
 *
 * If the section's sub items are an array
 * the 'slug name' is used for the link,
 * if the section's sub item is a string,
 * the string is used for the link.
 *
 * Optionally check any section given as a parameter.
 */
function get_section_link($section = '', $section_sub = '')
{
    global $_section;
    # Use the current section unless a specific section is given as a parameter
    $section = use_default($section, $_section);
    # if $section_sub is undefined, get it from the sitemap
    if (!$section_sub) {
        $sitemap = get_sitemap();
        $section_sub = $sitemap[$section];
    }
    $link = '';
    if (is_array($section_sub)) {
        if (has_index_pages()) {
            $link .= slug_name($section);
            $link .= '.php';
        } else {
            $link .= get_first_unnested_item($section_sub);
            # link to first sub item that isn't a nested array
        }
    } elseif (is_string($section_sub)) {
        $link = $section_sub;
    }
    return $link;
}