Nicholas Cheek

LITTLE ROCK WEB DEVELOPER

<?php
$pieces = parse_url($_SERVER['REQUEST_URI']);
$path = trim($pieces['path'], '/');
$segments = explode('/', $path);
$toplast = end($segments);
$topprev = prev($segments);
$query = $this->EE->db->query("SELECT site_pages FROM exp_sites");
$urlnum = $_SERVER["PHP_SELF"];
//echo $urlnum;
if ($query->num_rows() > 0) {
foreach ($query->result_array() as $row) {
//decode site pages from database
$answer = unserialize(base64_decode($row['site_pages']));
//echo "<pre>";
//var_dump($answer);
//echo "</pre>";
//end has to preceed prev
end($segments);

//setup variables to count the level we are on
$setup = trim($_SERVER["PHP_SELF"], '/');
$setupcount = explode('/', $setup);
$countnum = count($setupcount);

//---------------------------------------------------
//Here we need to do something with the dept interior
//so we can adjust the sidemenu for interior pages
//echo $countnum;
$searchurl = explode("/index.php/", $setup);
$spliturl = explode('/', $searchurl[1]);
$urlnum = count($spliturl);

//I'm going to use a goto here so we can jump to interior
//code and bypass the 'homepage' code

if ($urlnum != 2) {

goto interiorcode;
} else {
goto departmentmaincode;

}
//---------------------------------------------------
interiorcode:
$seg = end($segments);

$search = preg_grep("/$spliturl[1]/", $answer[1]["uris"]);

// This needs to be changed when it goes live.
$shorturl = ltrim(rtrim($answer[1]['url'], "/"), "http://www.inthooz.me");
//loop each url, adding the domain to the front to
//keep it the same format as the rest
foreach ($search as $key => $res) {
$tags = explode('/', $shorturl . $res);


//after we count we find all url's that have one more level
if (count($tags) == $countnum - 1) {


//query the database to get the page title for asthetic purposes

$query2 = $this->EE->db->query("SELECT title FROM exp_channel_titles WHERE entry_id =$key");
if ($query2->num_rows() > 0) {
foreach ($query2->result_array() as $newrow) {


echo "<div class='accordionButton'>";
echo $newrow['title'];
echo "</div>";
echo "<div class='accordionContent'>";

//here we need to pretty much do it all over again
//in order to find the children nav
//start
$childurl = explode('/', $res);
$lastseg = end($childurl);
$prevseg = prev($childurl);
$theurl = $prevseg . "/" . $lastseg;
$grandkids = preg_grep("/$prevseg/", $answer[1]["uris"]);
$newkids = preg_grep("/$lastseg/", $grandkids);
$kidcount = 0;
foreach ($newkids as $key => $kiddo) {
//echo $key . "<br />";
$kidcount++;

if ($kidcount != 1) {
$gkend = explode('/', $kiddo);
$gklast = end($gkend);
$query4 = $this->EE->db->query("SELECT title,url_title FROM exp_channel_titles WHERE entry_id =$key");

if ($query4->num_rows() > 0) {
foreach ($query4->result_array() as $anotherrow) {
//echo $anotherrow['title'];
// echo "<br />";
$urltitle = $anotherrow['url_title'];
$thenewlink = rtrim($answer[1]['url'], '/');

echo "<a href='";
//build the link
echo $thenewlink . $answer[1]["uris"][$key];
echo "'>";
echo $anotherrow['title'];
echo "</a>";
}
echo "<br />";
}
}
}
//

//stop
echo "</div>";
}
}
}
}

departmentmaincode:
$seg = end($segments);
$search = preg_grep("/$seg/", $answer[1]["uris"]);
// This needs to be changed when it goes live.
$shorturl = ltrim(rtrim($answer[1]['url'], "/"), "http://www.inthooz.me");
//loop each url, adding the domain to the front to
//keep it the same format as the rest
foreach ($search as $key => $res) {
$tags = explode('/', $shorturl . $res);

//after we count we find all url's that have one more level
if (count($tags) == $countnum + 1) {


//query the database to get the page title for asthetic purposes
$query2 = $this->EE->db->query("SELECT title FROM exp_channel_titles WHERE entry_id =$key");
if ($query2->num_rows() > 0) {
foreach ($query2->result_array() as $newrow) {


echo "<div class='accordionButton'>";
echo $newrow['title'];
echo "</div>";
echo "<div class='accordionContent'>";

//here we need to pretty much do it all over again
//in order to find the children nav
//start
$childurl = explode('/', $res);
$lastseg = end($childurl);
$prevseg = prev($childurl);
$theurl = $prevseg . "/" . $lastseg;
$grandkids = preg_grep("/$prevseg/", $answer[1]["uris"]);
$newkids = preg_grep("/$lastseg/", $grandkids);
$kidcount = 0;
foreach ($newkids as $key => $kiddo) {
//echo $key . "<br />";
$kidcount++;

if ($kidcount != 1) {
$gkend = explode('/', $kiddo);
$gklast = end($gkend);
$query4 = $this->EE->db->query("SELECT title,url_title FROM exp_channel_titles WHERE entry_id =$key");

if ($query4->num_rows() > 0) {
foreach ($query4->result_array() as $anotherrow) {
//echo $anotherrow['title'];
// echo "<br />";
$urltitle = $anotherrow['url_title'];
$thenewlink = rtrim($answer[1]['url'], '/');

echo "<a href='";
//build the link
echo $thenewlink . $answer[1]["uris"][$key];
echo "'>";
echo $anotherrow['title'];
echo "</a>";
}
echo "<br />";
}
}
}
//

//stop
echo "</div>";
}
}
}
}
}
}
?>

LITTLE ROCK WEB DEVELOPER

Living the dream.

nick@nicholascheek.com