e107 icon indicating copy to clipboard operation
e107 copied to clipboard

problem with not simple footer menu areas and menu manager

Open Jimmi08 opened this issue 6 years ago • 4 comments

Just recapitulation:

  • you have 3 places where menus are used
  1. of course Frontend
  2. left side of menu manager (where you click on Go button and available areas are displayed)
  3. theme preview in Menu manager (where used menus in menu areas are displayed) in iframe

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 avatar Oct 28 '19 11:10 Jimmi08

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

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

Jimmi08 avatar Jan 07 '20 20:01 Jimmi08

@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

CaMer0n avatar Mar 01 '20 21:03 CaMer0n

@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 avatar Jun 19 '21 20:06 Jimmi08

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

Jimmi08 avatar Mar 29 '24 21:03 Jimmi08