GetSimple Support Forum
If page is empty than it works like a trigger to open sublevel pages with content - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: Feature Requests (http://get-simple.info/forums/forumdisplay.php?fid=7)
+--- Thread: If page is empty than it works like a trigger to open sublevel pages with content (/showthread.php?tid=5638)



If page is empty than it works like a trigger to open sublevel pages with content - lifeisshort - 2014-02-13

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?


RE: If page is empty that it is like trigger to open sublevels - shawn_a - 2014-02-13

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.


RE: If page is empty than it works like a trigger to open sublevel pages with content - lifeisshort - 2014-02-13

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?


RE: If page is empty than it works like a trigger to open sublevel pages with content - Everyone - 2014-02-17

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_slugfalse );

    if( !
$entries )
        
$entries return_i18n_menu_data$current_slug099I18N_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.


RE: If page is empty than it works like a trigger to open sublevel pages with content - lifeisshort - 2014-02-20

Thank you, but maybe you can explain how to integrate this modification? And how to call this tree in sidebar. Thank you!


RE: If page is empty than it works like a trigger to open sublevel pages with content - morvy - 2015-02-16

.. 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..) ?