e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
318 stars 213 forks source link

problem with not simple footer menu areas and menu manager #3987

Open Jimmi08 opened 4 years ago

Jimmi08 commented 4 years ago

Just recapitulation:

When you have only one footer, you put it directly in theme.html When you have one footer for layout, you can put it in layout html files.

But when you want to let user decide what footer to use for each layout, then you need custom solution. All footers are in separate files and the user can select one of them.

Normally (before) I had custom theme shortcode for it, like this:

    function sc_layout_footer($parm)
    {
        $footer = varset( $this->customlayout['layout_footer'] , "footer_default");
        $footerpath = e_THEME. $this->sitetheme.'/footers/'.$footer.$this->file_extension;

        if(file_exists($footerpath)) {
            $text = file_get_contents($footerpath); 
            $text = e107::getParser()->parseTemplate($text);      
        } 
        else $text = '';
        return $text;
   }

of course, it stopped now to work.

So I changed this shortcode to magical shortcode {---FOOTER---} for variable footers. See description, it is for this purpose now.

This way:

    /**
     * Special Footer Shortcode for dynamic menuarea templates.
     * @shortcode {---FOOTER---}
     * @return string
     */
    function sc_footer()
    {
        $footer = varset( $this->customlayout['layout_footer'] , "footer_default");
        $footerpath = e_THEME. $this->sitetheme.'/footers/'.$footer.$this->file_extension;

        if(file_exists($footerpath)) {
            $text = file_get_contents($footerpath); 
                    $text = e107::getParser()->parseTemplate($text);   
                }   
        } 
      else $text = '';     
        return $text ;    
   }

This code breaks Menu manager. It's because of parse template code (but it is needed for Frontend)

After changing

        if(USER_AREA) {
        $text = e107::getParser()->parseTemplate($text);   
    }

Menus select works. But preview not. Menu is displayed but that blue area is not.

After changing

       if(USER_AREA AND !$_GET['configure']) {
        $text = e107::getParser()->parseTemplate($text);   
    }

blue areas are displayed. But it means I can use url parameter configure in future.

Should this work this way? It took me hours to find a working solution because I am not familiar with how the menu manager works.

Jimmi08 commented 4 years ago

It looks like related to this: https://github.com/e107inc/e107/issues/4057

You shouldn't use ParseTemplate() in magical shortcodes.

CaMer0n commented 4 years ago

@Jimmi08 I was able to use parseTemplate() inside the footer magic shortcode, so it must be caused by something else.

/**
     * Special Footer Shortcode for dynamic menuarea templates.
     * @shortcode {---FOOTER---}
     * @return string
     */
    function sc_footer()
    {
        $template = "<div class='text-center'>Hello {SITENAME}</div>";
        return e107::getParser()->parseTemplate($template, true);

    }

image

Jimmi08 commented 3 years ago

@CaMer0n I know where is problem. You tried something else than me. I have a problem with footer menus.

    function sc_footer()
    {
        $template = "<div class='text-center'>Hello {SITENAME} {MENU=101}</div>";
        return e107::getParser()->parseTemplate($template, true);

    }

You will see that the menu area is not displayed in the layout preview... Neither in the menu manager.

Jimmi08 commented 3 months ago

https://github.com/e107inc/e107/discussions/5226