Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

The top menu as a panel.

Asked Modified Viewed 2,463 times
D
djdandi
D
  • Senior Member, joined since
  • Contributed 298 posts on the community forums.
  • Started 99 threads in the forums
  • Started this discussions
asked
Senior Member

Hi, how can I top menu to add to the panel?

I copied some code Mainframe.php but it does not work.
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHPFusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: /Nebula/Mainframe.php
| Author: Hien (Frederick MC Chan)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/

namespace ThemePack\Nebula;

use PHPFusion\SiteLinks;
use ThemeFactory\Core;

class MainFrame extends Core {
   
    private function NebulaHeader() {
        echo renderNotices(getNotices(array('all', FUSION_SELF)));
        $defaultBg = ($this->getParam('headerBg') === TRUE ? " class=\"headerBg\"" : "");
        $headerBg = ($this->getParam('headerBg_class') ? " class=\"".$this->getParam('headerBg_class')."\"" : $defaultBg);
        echo "<header ".$headerBg.">\n";
        echo "<div class='headerInner'>\n";
      
      
        $menu_config = [
            'container' => TRUE,
            'navbar_class' => 'navbar-default',
            'language_switcher' => TRUE,
            'searchbar' => TRUE,
            'caret_icon' => 'fa fa-angle-down',
            'show_banner' => TRUE,
            'grouping' => fusion_get_settings('links_grouping'),
            'links_per_page' => fusion_get_settings('links_per_page'),
            'show_header' => TRUE
        ];
      
        echo SiteLinks::setSubLinks($menu_config)->showSubLinks();
        add_to_jquery("
         $('#".SiteLinks::MenuDefaultID."').affix({
            offset: {
               top: 100,
               bottom: function () {
                  return (this.bottom = $('.footer').outerHeight(true))
               }
            }
         })
      ");
      
   }
}
djdandi attached the following file:
2_6.png [No information available / 78 Downloads]
0 replies

10 posts

C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Don't quite get what you want.

... to "add to the panel" as in PANEL - LEFT, RIGHT, BL_LOWER?

You want to add your menu into which Panel?

I can guide only if I know what you want exactly.. :)
0 replies
D
djdandi
D
  • Senior Member, joined since
  • Contributed 298 posts on the community forums.
  • Started 99 threads in the forums
  • Started this discussions
answered
Senior Member

I want to get rid of the top menu in the theme and I want to add to the menu in the widget on additional pages. Understand?
djdandi attached the following file:
3_1.png [No information available / 69 Downloads]
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Copy line 33-57 into your menu__panel.php
Then delete the hard coded one in the theme header.
0 replies
D
djdandi
D
  • Senior Member, joined since
  • Contributed 298 posts on the community forums.
  • Started 99 threads in the forums
  • Started this discussions
answered
Senior Member

I changed the content menu_panel.php
<?php
/*-------------------------------------------------------+
| PHPFusion Content Management System
| Copyright (C) PHPFusion Inc
| https://www.php-fusion.co.uk/
+--------------------------------------------------------*/

      
        $menu_config = [
            'container' => TRUE,
            'navbar_class' => 'navbar-default',
            'language_switcher' => TRUE,
            'searchbar' => TRUE,
            'caret_icon' => 'fa fa-angle-down',
            'show_banner' => TRUE,
            'grouping' => fusion_get_settings('links_grouping'),
            'links_per_page' => fusion_get_settings('links_per_page'),
            'show_header' => TRUE
        ];
      
        echo SiteLinks::setSubLinks($menu_config)->showSubLinks();
        add_to_jquery("
         $('#".SiteLinks::MenuDefaultID."').affix({
            offset: {
               top: 100,
               bottom: function () {
                  return (this.bottom = $('.footer').outerHeight(true))
               }
            }
         })
      ");
   

I removed the same code in the file MainFrame.php but the menu did not work. Nothing displays.

Quote

Response: You have a namespace error. The thing is, you need to always use the full namespace if you're unsure. Since your panel is not defined any class, and did not assign any namespace, our autoloader won't be able to find Sitelinks class. Please review my answer below this.
Edited by Chan on 31-01-2017 14:30,
djdandi attached the following file:
4.png [No information available / 72 Downloads]
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

<?php

$menu_config = [
    'container' => TRUE,
    'navbar_class' => 'navbar-default',
    'language_switcher' => TRUE,
    'searchbar' => TRUE,
    'caret_icon' => 'fa fa-angle-down',
    'show_banner' => TRUE,
    'grouping' => fusion_get_settings('links_grouping'),
    'links_per_page' => fusion_get_settings('links_per_page'),
    'show_header' => TRUE
];

echo \PHPFusion\SiteLinks::setSubLinks($menu_config)->showSubLinks();
add_to_jquery("
 $('#".\PHPFusion\SiteLinks::MenuDefaultID."').affix({
    offset: {
       top: 100,
       bottom: function () {
          return (this.bottom = $('.footer').outerHeight(true))
       }
    }
 })
");


I have tested myself. If don't work for you, make sure you have the latest custom page git.

You do understand this method only work for 1 single page, and it's going to be troublesome to add every page?
Edited by Chan on 31-01-2017 14:10,
Chan attached the following file:
menu.png [No information available / 79 Downloads]
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Few method you can do:

$menu_config = [
    'container' => TRUE,
    'navbar_class' => 'navbar-default',
    'language_switcher' => TRUE,
    'searchbar' => TRUE,
    'caret_icon' => 'fa fa-angle-down',
    'show_banner' => TRUE,
    'grouping' => fusion_get_settings('links_grouping'),
    'links_per_page' => fusion_get_settings('links_per_page'),
    'show_header' => TRUE
];

echo \PHPFusion\SiteLinks::setSubLinks($menu_config)->showSubLinks();
add_to_jquery("
 $('#".\PHPFusion\SiteLinks::MenuDefaultID."').affix({
    offset: {
       top: 100,
       bottom: function () {
          return (this.bottom = $('.footer').outerHeight(true))
       }
    }
 })
");

\PHPFusion\Panels::addPanel('my_menu_bind', \PHPFusion\SiteLinks::setSubLinks($menu_config)->showSubLinks(), \PHPFusion\Panels::PANEL_U_CENTER, iGUEST, 1);


If it's in your code, you can use the new Panel Class API to bind content 'on-the-go' basis.

Lots of ways you go can go about this in PF9.

Fusion Theme also have such API you can utilize.

\ThemeFactory\Core::setParam('header_content', \PHPFusion\SiteLinks::setSubLinks($menu_config)->showSubLinks());


And the other method is custom page of course, which you're already using.

If you use addpanel() function -- The Panel side list for your reference:

\PHPFusion\Panels::PANEL_U_CENTER;
\PHPFusion\Panels::PANEL_L_CENTER;
\PHPFusion\Panels::PANEL_RIGHT;
\PHPFusion\Panels::PANEL_LEFT;
\PHPFusion\Panels::PANEL_AU_CENTER;
\PHPFusion\Panels::PANEL_BL_CENTER;
\PHPFusion\Panels::PANEL_USER1;
\PHPFusion\Panels::PANEL_USER2;
\PHPFusion\Panels::PANEL_USER3;
\PHPFusion\Panels::PANEL_USER4;


USER1-USER4 is added in last few days, and there is currently no theme that supports it yet.

Regardless, all methods give you the speediest available method. So no worries there.

Documentation will arrive only after we release new website. So before that, you can ask anything in the forum.
Edited by Chan on 31-01-2017 14:27,
0 replies
D
djdandi
D
  • Senior Member, joined since
  • Contributed 298 posts on the community forums.
  • Started 99 threads in the forums
  • Started this discussions
answered
Senior Member

:G
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

If you know how to use the Output Handler, it is also a method to inject things around PF9... but could be the slowest method among these suggested ones because it uses preg_replace method for injection while the above suggested ones uses 'buffer' and instance method.

To access the output handling class from your panel file without any need to require anything. Do:

\PHPFusion\OutputHandler::


For example, if you want to run a custom function to do something globally.

function somefunction() {
...
}

\PHPFusion\OutputHandler::addHandler(somefunction);


and for your case:


/**
     * Replace something in the output using regexp
     *
     * @param string $target Regexp pattern without delimiters
     * @param string $replace The new content
     * @param string $modifiers Regexp modifiers
     */
    public static function replaceInOutput($target, $replace, $modifiers = "") {
        self::$outputHandlers[] = function ($output) use ($target, $replace, $modifiers) {
            return preg_replace('^'.preg_quote($target, "^").'^'.$modifiers, $replace, $output);
        };
    }
Edited by Chan on 31-01-2017 14:39,
0 replies
D
djdandi
D
  • Senior Member, joined since
  • Contributed 298 posts on the community forums.
  • Started 99 threads in the forums
  • Started this discussions
answered
Senior Member

The more I meant to upper menu was displayed on the home page and other sites a little different top menu.
But I see that it is through additional pages will not come out.
Something like that
home.php
http://themehats.com/themes/jango/index.html
Another page other menu
http://themehats.com/themes/jango/home-4.html
How can I achieve this?
0 replies
C
Chan
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
answered
Super Admin

Quote

<?php

$menu_config = [
    'container' => TRUE,
    'navbar_class' => 'navbar-default',
    'language_switcher' => TRUE,
    'searchbar' => TRUE,
    'caret_icon' => 'fa fa-angle-down',
    'show_banner' => TRUE,
    'grouping' => fusion_get_settings('links_grouping'),
    'links_per_page' => fusion_get_settings('links_per_page'),
    'show_header' => TRUE
];

echo \PHPFusion\SiteLinks::setSubLinks($menu_config)->showSubLinks();
add_to_jquery("
 $('#".\PHPFusion\SiteLinks::MenuDefaultID."').affix({
    offset: {
       top: 100,
       bottom: function () {
          return (this.bottom = $('.footer').outerHeight(true))
       }
    }
 })
");


I have tested myself. If don't work for you, make sure you have the latest custom page git.

You do understand this method only work for 1 single page, and it's going to be troublesome to add every page?
- by Chan


See I said that earlier. For 1 single case use its ok, but you're talking about menu here where usage is on all page.

In this case, I would advice to use the theme to do the menu as original method.

I'll explain case studies on new php-fusion.co.uk site which I'm working on. I am using Fusion Theme because it provides a good core with functions I need. So, I duplicate NebulaTheme and make a new Theme Pack.

With this, all my files mod, templates I can access modifiers with - \ThemeFactory\Core::any_static_function($any_param);
I can work on custom infusions and in their respective templates access my theme with that function as well.

To try what I'm saying, as long as you use Nebula Theme, go to ANY template, ANY file.. then do:

\ThemeFactory\Core::setParam('LEFT', FALSE);


will shut down the LEFT panel section.

This makes me able to control my theme without need to edit the theme at all for a single use. (I.e. In News, I dont want to see Left Panel)
However, the better way also like this:

Panels::getInstance()->hide_panel('LEFT');


------------------

Now lets get your environment straight.

You fork your theme, if it's FusionTheme RC5, then duplicate and fork ThemePack (see screenshot). Directly edit HTML and make the menu.
Note: you need to enable your theme pack in Theme Engine Admin.

It's the most straightforward case for you.

Those APIs and Widgets are just useful if it's a Single Use. But for your menu, it's Global use. So question is why you used widget in the first place. Why not normally edit the theme and add it in.
Chan attached the following file:
fork.png [No information available / 67 Downloads]
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 10 posts
  • Votes 0 votes
  • Topic users 2 members

2 participants

C
C
Chan 0
Lead Developer of PHP-Fusion
  • Super Admin, joined since
  • Contributed 3,841 posts on the community forums.
  • Started 232 threads in the forums
  • Answered 6 questions
D
D
  • Senior Member, joined since
  • Contributed 298 posts on the community forums.
  • Started 99 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet