2014-11-22, 10:10:07
(2014-11-21, 17:59:42)davetest Wrote: Thanks Lesh, your script works great for creating the sub pages displayed within/below their parent page. Now all I need to do is find a way to not have to manually build the 'in-page' menus to link to anchors at the head of the sub-page sections. Any ideas?
I have wanted to solve this for ages and an "Auto sub-page-nav" was the other thing I had to do.
I have moved the part of the code that collects and sortds the pages outside the content section and added a loop to putput a list of links to the articles/subpages called "subnav".
which could be made a static block in a sidebar or top-bar using CSS.
PHP Code:
<?php /* get the pages and sort them */
global $pagesArray;
$pagesSorted = subval_sort($pagesArray,'menuOrder'); // or 'title', 'menu', 'url', ...
$thisPage = return_page_slug();
?>
<div id="container">
<ul id="subnav"> <!-- fixed sidebar -->
<li> <a href="#top">Top of Page</a> </li>
<?php /* output a nav list for the subpages */
foreach ($pagesSorted as $page) if ($page['parent']==$thisPage && $page['private']!='Y') {
$pag = $page['url']; ?>
<li> <a href="#<?php echo $pag; ?>"><?php getPageField($pag,'menu'); ?></a> </li>
<?php } ?>
</ul>
<main id="content" class="rowp">
<a id="top"></a>
<?php /* output the subpages as articles or sections */
foreach ($pagesSorted as $page) if ($page['parent']==$thisPage && $page['private']!='Y') {
$pag = $page['url']; ?>
<article class="subpage <?php echo $pag; ?>">
<a id="<?php echo $pag; ?>"></a>
<h2><?php getPageField($pag,'title'); ?></h2>
<div class="subcontent">
<?php getPageContent($pag); ?>
</div>
</article>
<?php } ?>
</main>
</div>
Also
There is a plugin in extend - SA TOC Anchors - that makes nav links to headings in the page.