Commit 3afad25c by Aleksandar Hristov

sidebar menu

1 parent b9b138e7
......@@ -24,6 +24,20 @@ function get_pages()
return $db_page_title;
}
//function that returns all the page id's in the database in an array
function get_pages_id()
{
global $db;
$i=0;
$query=$db->query("SELECT * FROM pages");
while($row=$query->fetchArray())
{
$pages_id[$i]=$row[0];
$i++;
}
return $pages_id;
}
//function that returns all the sections in the database in an array in format "page: section"
function get_sections()
{
......@@ -66,7 +80,7 @@ function current_page()
return $current_page;
}
//function that returns all the sections that belong to a specific page
//function that returns all the sections titles that belong to a specific page
function page_sections($page)
{
global $db;
......@@ -86,3 +100,33 @@ function page_sections($page)
return $sections;
}
//function that returns section id
function return_section_id($section_title)
{
global $db;
$query = $db->query("SELECT * FROM sections");
$i=0;
while ($row=$query->fetchArray())
{
if ($row[3]==$section_title)
{
break;
}
}
return $i;
}
function return_page_id($page_title)
{
global $db;
$page_id = $db->querySingle("SELECT id FROM pages WHERE title = '$page_title'");
return $page_id;
}
\ No newline at end of file
......@@ -50,6 +50,10 @@ while ($row=$query->fetchArray())
}
}
$smarty->assign("current_page", $current_page);
$smarty->assign("page_id", $page_id);
$smarty->assign("page_title", $page_title);
$smarty->assign("page_text", $page_text);
......@@ -58,6 +62,7 @@ $smarty->assign("section_title", $section_title);
$smarty->assign("section_text", $section_text);
$smarty->assign("pages", get_pages());
$smarty->assign("pages_id", get_pages_id());
$smarty->display("tpl/index.tpl");
......
......@@ -7,15 +7,30 @@
</a>
</li>
{section name=pages loop=$pages}
{if $pages_id[pages] eq $current_page}
<li class="has-sub active" id="active">
<a href="#">
{else}
<li class="has-sub">
<a href="#">
{/if}
{$pages[pages]}<i class="fa fa-chevron-right fa pull-right chevron-margin" id="valign-icon"></i>
</a>
<ul>
<!-- sections here -->
{assign var=var value=1}
{foreach page_sections($pages[pages]) as $section_title}
{assign var=current_page_id value=return_page_id($pages[pages])}
{assign var=link value="?$current_page_id#$var"}
<li><a href={$link} class="sub-text-padding">{$section_title}</a></li>
{assign var=var value=$var+1}
{/foreach}
</ul>
</a>
</li>
{/section}
<li id="copyright">© 2013 - 2015 slimspots.com</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!