by
Gizmo » Wed Apr 16, 2014 5:24 pm
Hello KK,
I'll explain my problem.
Back in December I posted
viewtopic.php?f=4&t=7821I managed to find a solution based on pages but without creating my own admin screen.
Everything worked on the frontend but in the backend I couldn't get sorting the pages to work like I wanted. In the end sorting based on date was the best I could get to work although sorting on folder would have been the best solution.
Lately I got back to your nested_pages solution. I rebuild the code so everything working like the pages version but now with ordering possible in the backend. Your solution worked like a charm (Thanks for helping me find the solution) but for the purpose I needed I had to rewrite a bit.
I came up with the following solution:
The index page shows the title and all the chapters that have subpages. Selecting a chapter jumps straight to the first page of this chapter. Using this in combination with a bit of jQuery code it became possible to browse the articles of a chapter just like paginate does with some visual goodies.
index.php
- Code: Select all
<div class="content">
<cms:show index_title />
<div>
<ul class="menu">
<cms:nested_pages masterpage='chapters.php' depth='1' >
<li><a href="<cms:show k_nestedpage_link />"><cms:show k_nestedpage_title /></a></li>
</cms:nested_pages>
</ul>
</div>
</div>
chapters.php:
- Code: Select all
<cms:if k_is_page>
<cms:if k_nested_parent_id='-1'>
<cms:nested_pages masterpage='chapters.php' include_custom_fields='1' childof=k_page_name >
<div class="content">
<h1><cms:show k_nestedpage_title /></h1>
<cms:show content_nested />
</div>
</cms:nested_pages>
<cms:else />
<cms:nested_pages masterpage='chapters.php' include_custom_fields='1' root=k_page_name >
<div class="content">
<h1><cms:show k_nestedpage_title /></h1>
<cms:show content_nested />
</div>
</cms:nested_pages>
</cms:if>
</cms:if>
<cms:if k_is_list>
<cms:nested_pages masterpage='chapters.php' include_custom_fields='1' childof=k_page_name >
<div class="content">
<h1><cms:show k_nestedpage_title /></h1>
<cms:show content_nested />
</div>
</cms:nested_pages>
</cms:if>
A submenu.html snippet included in the chapters.php shows the the chapter menu and the articles belonging to a chapter.
- Code: Select all
<!-- chapter menu -->
<cms:nested_pages masterpage='chapters.php' extended_info='1' depth='1' >
<cms:if k_level_start >
<cms:if k_level='0'>
<ul class="chapterMenu">
<cms:else />
<ul>
</cms:if>
</cms:if>
<cms:if k_element_start >
<li id="item-<cms:show k_nestedpage_name />" class="level-<cms:show k_level/><cms:if k_total_children> has-submenu</cms:if><cms:if k_first_child> first</cms:if><cms:if k_last_child> last</cms:if><cms:if k_is_active> active</cms:if><cms:if k_is_current> current</cms:if>">
<a href="<cms:show k_menu_link />"><cms:show k_menu_title /></a>
</cms:if>
<cms:if k_element_end ></li></cms:if>
<cms:if k_level_end ></ul></cms:if>
</cms:nested_pages>
<!-- article based on article menu -->
<ul id="menu-toc" class="menu-toc">
<cms:nested_pages masterpage='chapters.php' childof=k_page_name >
<li><a href="<cms:show k_nestedpage_link />"><cms:show k_nestedpage_title /></a></li>
</cms:nested_pages>
</ul>
This is a working solution. This shows all chapters in the chapter menu. But what I'm trying to achieve is a solution that shows only the previous and next chapter based on the current chapter selected.
To sum it all up:
- index.php shows only all the chapters, no submenu is shown;
- selecting a chapter on the index.php jumps straight to the first article of a chapter;
- chapters.php has a submenu with two menu's one for the chapters and one for the articles of a chapter.
- the Chapter1 and Chapter2 pages are only visible in listview which makes chapterMenu obsolete because all pages are shown in the menu-toc;
I hope my long post gives you a good idea how the website functions.