Posts: 4
Threads: 1
Joined: Feb 2014
2014-02-13, 04:10:29
(This post was last modified: 2014-02-13, 04:15:42 by lifeisshort.)
Hello,
i want to say big thank you for such a good cms!
I want to create a documentation page with a tree. Everything works fine, i am using i18n plugin to show a structure tree. The only problem is that even if i leave page empty and i click on it in a tree, it is loaded empty.
I want that left empty pages become as a separators which will expand sublevel pages with content
Like this: http://www.dynamicdrive.com/dynamicindex1/treeview/
Maybe someone can point me to the right direction?
Posts: 6,267
Threads: 182
Joined: Sep 2011
So you want fake parents, that are not actual pages or linked to actual pages ?
You can probably get what you want using the custom module option of i18n nav if you know php.
Posts: 4
Threads: 1
Joined: Feb 2014
2014-02-13, 08:06:20
(This post was last modified: 2014-02-13, 15:22:44 by lifeisshort.)
Yes, you are right! I edited plugins/sitemap.php and found this:
function sm_get_link($page) {
$url = $page['url'];
$title = $page['title'];
return "<a href=\"$url\">$title</a>";
}
How to detect if page has no data in it, than this function return only page name without link, and if it is normal page with content, than it will be normal link.
Or there is another way to modify standard page structure tree?
Posts: 52
Threads: 2
Joined: May 2013
2014-02-17, 08:08:03
(This post was last modified: 2014-02-22, 21:20:13 by Everyone.)
I had a simmilar need, so I came up with this. It uses i18n plugin's navigation API functions.
PHP Code:
function custom_tree_nav( $current_slug = null, $entries = false )
{
$current_slug = $current_slug ? $current_slug : get_page_slug( false );
if( !$entries )
$entries = return_i18n_menu_data( $current_slug, 0, 99, I18N_SHOW_MENU );
echo '<ul>';
foreach( $entries as $entry )
{
# 'current' menu entry class tag.
$current = $entry['current'] ? ' current' : '';
# Get menu name, or page name if menu name empty.
$menu = $entry['menu'] ? $entry['menu'] : $entry['title'];
# This may need to be adjusted according to installation specifics
$slug = '/'.$entry['url'];
$url = $entry['url'];
if( !empty( $entry['children'] ) )
{
# Might want to throw an 'a' instead of 'span'.
echo '<li><span class="'.$url.$current.'">'.$menu.'</span>';
custom_tree_nav( $current_slug, $entry['children'] );
echo '</li>'."\n";
}
else
echo '<li><a class="'.$url.$current.'" href="'.$slug.'" target="_self">'.$menu.'</a></li>'."\n";
}
echo '</ul>'."\n";
}
Put this function in your theme's
functions.php file, then call it from your template file like this:
<?php custom_tree_nav(); ?>
It will create the raw HTML menu code. Be aware that no checks are made whether a page is empty or not, rather a page is checked for existence of children. Also, no attempt was made to recreate the url structure, as GS will (with proper configuration) accept anything after the last slash as a page slug, and return the correct page.
Any CSS styling + JS behavior is up to you.
Posts: 4
Threads: 1
Joined: Feb 2014
2014-02-20, 03:29:54
(This post was last modified: 2014-02-20, 16:09:47 by lifeisshort.)
Thank you, but maybe you can explain how to integrate this modification? And how to call this tree in sidebar. Thank you!
Posts: 185
Threads: 8
Joined: Apr 2012
.. I know that this is old thread, but I think it's really a good idea. all bigger CMS systems have possibility to add "divider" into menu, so there is no page related to it. I was thinking about adding checkbox in menu section of page preferences, where I can select if I want normal page or just divider. but the idea with empty page to be automatically divider is really good. I know that this can be done by custom module in i18n, but what about sitemap? I don't want empty pages to be in sitemap, just their names in path for their children pages .. so do I need to hack everything just because I want parents non-clickable and maybe also parent that holds megamenu (where parent is a title for it's children..) ?