Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hack to generate submenus ...
#1
Hello ...
A little hack to genrate submenu of the current page

put this code in your template ...

Code:
<?php
$sm = '';

$sm1 = '';
$data=simplexml_load_string(menu_data('',true));
$topmenu= subval_sort($data->xpath("//*[menuStatus='Y']"),'menuOrder');
foreach ($topmenu as  $menu){
// output the top level menu items
   //$sm .= "<li>".$menu->slug."</li>";
   $submenus= $data->xpath("//*[parent='".$menu->slug."']");
// output submenu if it exists
   if (count($submenus) != 0) {  
    
     $sm1 = '';
     $sm1 .= "<ul class='submenu'>";
     if ( trim(return_page_slug()) == trim($menu->slug)) { $sm1ok = 1; } else {    $sm1ok = 0; }

     foreach ($submenus as $submenu){
        if ( trim(return_page_slug()) == trim($submenu->slug)) { $sm1ok = 1; }
         $sm1 .= '<li><a href="'.$menu->slug.'/'.$submenu->slug.'">'.$submenu->slug."</a></li>";
     }

    $sm1 .= "</ul>";
    if ($sm1ok == 1) {
        $sm .= $sm1;
     }
    
    }
}
echo $sm;
?>
Reply
#2
try this template ...
oops ...upload a zip don't work :'(

Code:
<?php
/****************************************************
*
* @File:             template.php
* @Package:        GetSimple
* @Action:        Default theme for the GetSimple CMS
*
*****************************************************/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title><?php get_page_clean_title(); ?> | <?php get_site_name(); ?>, <?php get_component('tagline'); ?></title>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <?php get_header(); ?>
    <meta name="robots" content="index, follow" />
    <link rel="stylesheet" type="text/css" href="<?php get_theme_url(); ?>/default.css" />
   <link rel="stylesheet" type="text/css" href="<?php get_theme_url(); ?>/css/all.css" />
   <script type="text/javascript" src="<?php get_theme_url(); ?>/js/jquery-1.4.1.min.js"></script>
   <script type="text/javascript" src="<?php get_theme_url(); ?>/js/jquery.dropDown.pack.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('ul.menu').NavDropDown();                  
        });    
    </script>
    <script type="text/javascript"><!--
        try {
            document.execCommand("BackgroundImageCache", false, true);
        } catch(err) {}
        /* IE6 flicker hack from http://dean.edwards.name/my/flicker.html */
    --></script>
</head>

<body id="<?php get_page_slug(); ?>" >
<div class="wrapper">
    <div id="header">
        <a class="logo" href="<?php get_site_url(); ?>"><?php get_site_name(); ?></a>
        <p class="tagline"><?php get_component('tagline'); ?></p>
        
            <?php menu_master (); ?>
        
    </div><!-- end div#header -->

    <div id="bodycontent">
    
        <div class="post">
            <h1><?php get_page_title(); ?></h1>
            <div class="postcontent gallerea">
                 <!--  <ul class="navy">
<?php // get_breadcrumbs(); ?>
</ul>   -->

<?php
$sm = '';

$sm1 = '';
$data=simplexml_load_string(menu_data('',true));
$topmenu= subval_sort($data->xpath("//*[menuStatus='Y']"),'menuOrder');
foreach ($topmenu as  $menu){
// output the top level menu items
   //$sm .= "<li>".$menu->slug."</li>";
   $submenus= $data->xpath("//*[parent='".$menu->slug."']");
// output submenu if it exists
   if (count($submenus) != 0) {  
    
     $sm1 = '';
     $sm1 .= "<ul class='submenu'>";
     if ( trim(return_page_slug()) == trim($menu->slug)) { $sm1ok = 1; } else {    $sm1ok = 0; }

     foreach ($submenus as $submenu){
        if ( trim(return_page_slug()) == trim($submenu->slug)) { $sm1ok = 1; }
         $sm1 .= '<li><a href="'.$menu->slug.'/'.$submenu->slug.'">'.$submenu->slug."</a></li>";
     }

    $sm1 .= "</ul>";
    if ($sm1ok == 1) {
        $sm .= $sm1;
     }
    
    }
}
echo $sm;
?>
          
                <?php
                
        
            
        


        get_page_content(); ?>
        

        
        
            </div>
            <p class="meta" >
                <b>Ссылка на страницу:</b> <?php get_page_url(); ?><br />
                <b>Опубликовано:</b> <?php get_page_date('d.m.Y'); ?>
            </p>
        </div>
    </div><!-- end div#bodycontent -->
    
    <div id="sidebar">
        <div class="featured">
            <?php get_component('sidebar');    ?>
            <div class="clear"></div>
        </div>
    </div><!-- end div#sidebar -->
    
    <div class="clear"></div>    
    
    <div id="footer">
        <p class="left-footer"><?php echo date('Y'); ?> <strong><?php get_site_name(); ?></strong></p>
        <p class="right-footer"><?php get_site_credits(); ?><br /><a href="http://www.cagintranet.com" title="GetSimple Creators" >Theme by Cagintranet</a></p>
        <div class="clear"></div>
        
        <?php get_footer(); ?>
        
    </div><!-- end div#footer -->

</div><!-- end div.wrapper -->

</body>
</html>
Reply
#3
Note that using this script is going to make your website load a lot slower!

First to build your normal page menu every data file is opened, read, processed and closed again. Then when you come to this piece of code it will again open, read, process and close every data file. There is no caching for this implemented in any plugin as of yet. Running multiple menu generating pieces of code without building a caching system is not a very good idea.

After having said this, I’m glad you where able to get GetSimple display pages the way you want it!
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#4
yes ..I agree with you...
this is a little bad hack ... But this is the only way I found to get to this submenu...
If you have a better solution or a plugin, it would be realy fantastic!
I could see, Many people claim that this feature
May be a real plugin would be needed? no?
Reply
#5
yes ? no ?
no answer :'(
Reply
#6
Hello caviar,
Quote:A little hack to genrate submenu of the current page
Quote:May be a real plugin would be needed? no?

I have upload a plugin that does it: http://get-simple.info/forum/viewtopic.php?id=672

The style that show is into php; you can modify it as you like.

REgards.
Reply




Users browsing this thread: 1 Guest(s)