Interakt Menu Install

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
cuhlcannon
Forum Members
Forum Members
Posts: 30
Joined: Wed Jun 22, 2005 8:02 am

Interakt Menu Install

Post by cuhlcannon »

I have bought this plugin to make css menus, and spent some time using it on other sites and in other applications and I do like the format of it and how it works.

However, I was trying to move it to the new cms I found here, that I REALLY like. I have pored through the forums, and found a few tips: moving php to a user defined tag, putting {literal} around javascript calls, merging the style sheets into one {stylesheet} tag for my template.

And now I have a problem, on this page here:

http://82.195.146.84/index.php?page=Test

And I am not really sure why the error:

{nocache:289c2f560b8bbcf61c0c409d05274545#0}
Fatal error: Call to a member function on a non-object in /hsphere/local/home/kevanarm/luxfer.biz/lib/content.functions.php(441) : eval()'d code on line 2

...would come up?

I have asked on the menu creators forums as well, so I am waiting to see what they come back to me with.I am hoping the problem isn't in the code itself, but for some reason seems to be showing on my test page only where I have included the {menu} and {menu_render} tags. They are my user defined tags.  Hopefully to help and not to burden the page with a ton of code: here is the template part of it;


{menu}


{title}
{stylesheet}

{literal}



{/literal}







High Performance Engineering Materials



   

Luxfer is an international group of businesses that specialise in the design, manufacture and supply of high performance materials to engineering industry worldwide. The Group manufactures high pressure gas cylinders, various alloys of magnesium and components in aluminium and magnesium, and compounds of zirconium. Main markets served include automotive, aerospace and defence, medical and general engineering.



{bulletmenu}{menu_render}



Contact Us
Locations




  {content}

NEWS IN BRIEF

{cms_module module="news" number="5" summary="page" length="80" dateformat="M Y"}

 






Privacy
Security
Terms and Conditions






cuhlcannon
Forum Members
Forum Members
Posts: 30
Joined: Wed Jun 22, 2005 8:02 am

Re: Interakt Menu Install

Post by cuhlcannon »

And I got a reply from the creator of the menu:

"This is a smarty based doubt, the cache is the one that the engine uses on the 'compiling'.

The error seems to be related with smarty not being able to write something and reload the page that meanst that the cache id is not being refreshed which is what causes the incomplete output. I think the best is to recompile."

And I haven't much clue what this means. Does anyone have any tips?
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Interakt Menu Install

Post by Ted »

Did you create any user-defined tags(plugins)?  It looks like a user-defined tag has bad code in it.  CMSMS only checks to see that the code is valid php, it doesn't actually run through in the admin to make sure it works right.
cuhlcannon
Forum Members
Forum Members
Posts: 30
Joined: Wed Jun 22, 2005 8:02 am

Re: Interakt Menu Install

Post by cuhlcannon »

I have made 3 user tags, copied from the php created by the menu script:

{MX_menu}:
class MX_Menu {

  var $menuName;
  var $menuItems;
  var $menuOutput;
  var $DBItems;
 
  var $menuSkin;
  var $menuLayout;
  var $menuShowTimeout;
  var $menuHideTimeout;
  var $menuImgReplace;
  var $menuImgReplaceStyle;
  var $menuImgDir;
  var $menuImgNames;

  var $query;
  var $menuPK;
  var $menuFK;
  var $menuNameField;
  var $menuTitleField;
  var $menuLink;
  var $menuURLParameter;
  var $menuTarget;
  var $menuLinkField;
  var $menuTargetField;
  var $menuLevel;
  var $menuHighlight;

  var $isStatic;
  var $isStaticURL;
  var $previousItemLevel;

  function MX_Menu ($menuName, $menuDepthSeparator = ' ') {
    $this->menuName = $menuName;
    $this->menuDepthSeparator = $menuDepthSeparator;
    $this->menuItems = array();
    $this->DBItems = array();
    $this->previousItemLevel = -1;
    $this->menuLevel = -1; // -1 means menuLevel is not taken into account
    $this->menuHighlight = false;

    $this->menuImgReplace = 'no';
    $this->menuImgReplaceStyle = 'img';
    $this->menuImgDir = '';
    $this->menuImgNames = '';

    $this->menuOutput = '';
  }

  /*
  * Common setters (menu styling & behavior)
  */
  function setSkin ($menuSkin) {
    $this->menuSkin = trim($menuSkin);
  }

  function setLayout ($menuLayout) {
    $this->menuLayout = trim($menuLayout);
    if (strtolower($this->menuLayout) == 'tab') {
      $this->menuLayout = 'horizontal2';
      $this->menuLevel = 2; // force limit the number of the output levels for tab layout (see _renderStatic)
    }
  }

  function setShowTimeout ($menuShowTimeout) {
    $menuShowTimeout = is_numeric(trim($menuShowTimeout))?trim($menuShowTimeout):40;
    $this->menuShowTimeout = $menuShowTimeout;
  }

  function setHideTimeout ($menuHideTimeout) {
    $menuHideTimeout = is_numeric(trim($menuHideTimeout))?trim($menuHideTimeout):40;
    $this->menuHideTimeout = $menuHideTimeout;
  }

  function setImgReplace ($menuImgReplace = false) {
    $menuImgReplace = ($menuImgReplace === true)?'yes':'no';
    $this->menuImgReplace = $menuImgReplace;
  }

  function setImgReplaceStyle ($menuImgReplaceStyle = 'img') {
    $menuImgReplaceStyle = ($menuImgReplaceStyle == 'css')?'css':'img';
    $this->menuImgReplaceStyle = $menuImgReplaceStyle;
  }

  function setImgDir ($menuImgDir) {
    $this->menuImgDir = rawurlencode(trim($menuImgDir));
  }

  function setImgNames ($menuImgNames) {
    $this->menuImgNames = rawurlencode(trim($menuImgNames));
  }

  /*
  * Static Mx Menu
  */

  function addItem ($itemName, $itemURL, $itemTitle = '', $itemTarget='') {
    // sets static menu renderer
    $this->isStatic = true;
    $level = 0;
    while (strpos($itemName, $this->menuDepthSeparator) === 0) {
      $level++;
      $itemName = substr($itemName, 1);
    }
    $useThisEntry = true;
    if (($level > $this->previousItemLevel) && (($level - $this->previousItemLevel) > 1)) {
      $useThisEntry = false; // ignore this entry because more than 2 spaces from the previous level have been detected
      $level = $this->previousItemLevel + 1;
    }
    if ($useThisEntry) {
      $myItem = array();
      $myItem['itemName'] = htmlentities(stripslashes(trim($itemName)));
      $myItem['itemURL'] = trim($itemURL);
      $myItem['itemLevel'] = $level;
      $myItem['itemTitle'] = htmlentities(stripslashes(trim($itemTitle)));
      $myItem['itemTarget'] = $itemTarget;
      array_push($this->menuItems, $myItem);
      $this->previousItemLevel = $level;
    }
  }

  /*
  * Dynamic Mx Menu
  */

  function setQuery (&$query) {
    $this->query = $query;
    $this->isStatic = false;
    $this->isStaticURL = true;
  }

  function setPK ($menuPK) {
    $this->menuPK = trim($menuPK);
  }

  function setFK ($menuFK) {
    $this->menuFK = trim($menuFK);
  }

  function setNameField ($menuNameField) {
    $this->menuNameField = trim($menuNameField);
  }

  function setTitleField ($menuTitleField) {
    $this->menuTitleField = trim($menuTitleField);
  }

  function setLink ($menuLink) {
    $this->menuLink = trim($menuLink);
  }

  function setURLParameter ($menuURLParameter) {
    $this->menuURLParameter = trim($menuURLParameter);
  }

  function setTarget($menuTarget) {
    $this->menuTarget = trim($menuTarget);
  }

  function setLinkField ($menuLinkField) {
    $this->isStaticURL = false;
    $this->menuLinkField = trim($menuLinkField);
  }

  function setTargetField ($menuTargetField) {
    $this->menuTargetField = trim($menuTargetField);
  }

  function setLevel ($menuLevel = 3) {
  // if $menuLevel reset menuLevel
    $this->menuLevel = $menuLevel;
  }

  function highlightCurrent ($highlight = false) {
    if ($highlight === true) {
      $this->menuHighlight = true;
    } else {
      $this->menuHighlight = false;
    }
  }


  /*
  * Render wrapper
  */

  function render () {
    if (strlen($this->menuOutput) == 0) {
      if ($this->isStatic) {
        $this->menuOutput = $this->_renderStatic();
      } else {
        $this->menuOutput = $this->_renderDynamic();
      }
    }
    return $this->menuOutput;
  }


  /*
  *  Renderes
  */

  function _renderStatic () {
    $request_uri = $query_string = '';
    if (isset($_SERVER['SCRIPT_NAME'])) {
      $request_uri = $_SERVER['SCRIPT_NAME'];
    } elseif (isset($_ENV['SCRIPT_NAME'])) {
      $request_uri = $_ENV['SCRIPT_NAME'];
    }
    if (isset($_SERVER['QUERY_STRING'])) {
      $query_string = $_SERVER['QUERY_STRING'];
    } elseif (isset($_ENV['QUERY_STRING'])) {
      $query_string = $_ENV['QUERY_STRING'];
    }

    if (strlen($query_string) > 0) {
      $request_uri .= '?' . $query_string;
    }

    $div_start  = 'menuSkin . '">';
    $div_start .= 'menuLayout . ' ';

    $return  = '';
    $return .= $div_start;
    $return .= 'ktopts_showtimeout_' . $this->menuShowTimeout . ' ';
    $return .= 'ktopts_hidetimeout_' . $this->menuHideTimeout . ' ';
    $return .= 'ktopts_imgreplace_' . $this->menuImgReplace . ' ';
    $return .= 'ktopts_imgreplacestyle_' . $this->menuImgReplaceStyle . ' ';
    $return .= 'ktopts_imgdir_' . $this->menuImgDir . ' ';
    $return .= 'ktopts_imgnames_' . $this->menuImgNames . '">';
    $return .= "\r\n";
    $nextItemLevel = 0;

    // limit the output level for tab layout
    if ($this->menuLayout == 'horizontal2')  {
      $this->menuLevel = 2;
      $tmpArray = array();
      for ($i=0; $i menuItems); $i++) {
        if ($this->menuItems[$i]['itemLevel'] menuLevel) {
          $tmpArray[] = $this->menuItems[$i];
        }
      }
      $this->menuItems = $tmpArray;
    }

    for ($i=0; $i menuItems); $i++) {
      $myItem = $this->menuItems[$i];
      if ($i menuItems) - 1) ) {
      $nextItemLevel = $this->menuItems[$i + 1]['itemLevel'];
      } else {
      $nextItemLevel = 0;
      }
      $url = $myItem['itemURL'];
      $itemLi = '';
  if ($this->menuHighlight) {
  if ($this->checkHighlight($url, $request_uri)) {
$itemLi = '';
$this->menuHighlight = false;
}
  }
      $return .= $itemLi;
      $return .= ' 0) {
        $return .= ' target="' . $myItem['itemTarget'] . '"';
      }
      if (strlen($myItem['itemTitle']) > 0) {
        $return .= ' title="' . $myItem['itemTitle'] . '"';
      }
      $return .= '>';
      $return .= $myItem['itemName'];
      $return .= '';
      if ($nextItemLevel \r\n";
      }
      if ($nextItemLevel \r\n", $repeat);
      }
      if ($nextItemLevel > $myItem['itemLevel']) {
        $repeat = $nextItemLevel - $myItem['itemLevel'];
        $return .= str_repeat("\r\n", $repeat);
      }
    }
    $return .= "\r\n";
    $return .= "\r\n";
    if (count($this->menuItems) == 0) {
      $return = 'No data to render.';
    }
    return $return;
  }

  function isURLRelativeToDoc($url) {
    if ( strpos(strtolower($url), "/") === 0 || strpos(strtolower($url), "http://") !== false || strpos(strtolower($url), "https://") !== false ) {
      return false;
    }
    return true;
  }

  // checks if the current url from menu is highlighted (is the same as the current page url)
  function checkHighlight($url, $url_page) {
if ($this->isURLRelativeToDoc($url)) {
if ( strpos(strtolower($url_page), strtolower($url)) !== false &&
strlen(substr(strtolower($url_page), strpos(strtolower($url_page), strtolower($url)) + strlen($url))) ==0 ) {
return true;
}
} else {
if ( strpos(strtolower($url), strtolower($url_page)) !== false &&
strlen(substr(strtolower($url), strpos(strtolower($url), strtolower($url_page)) + strlen($url_page))) ==0 ) {
return true;
}
}
return false;
  }

  function _renderDynamic () {
    $this->_getUnformatedData();
    if (count($this->DBItems) > 0) {
      $this->_formatData(0, 0, $this->menuLevel);
    }
    return $this->_renderStatic();
  }

  function _getUnformatedData () {
    $this->DBItems = array();

    if (is_resource($this->query)) {
      include_once('MX_Menu_recordset.class.php');
      $rs = new MX_Menu_recordset($this->query);
    } else {
      $rs = &$this->query;
      $rs->MoveFirst();
    }

    while (!$rs->EOF) {
      $myItem = array();
      $myItem['itemName'] = htmlentities(stripslashes(trim($rs->Fields($this->menuNameField))));
      $target = '';
      if ($this->isStaticURL) {
        $url = $this->menuLink . $rs->Fields($this->menuURLParameter);
        $target = $this->menuTarget;
      } else {
        $url = $rs->Fields($this->menuLinkField);
        if (isset($this->menuTargetField) && strlen($this->menuTargetField) > 0) {
          $target = $rs->Fields($this->menuTargetField);
        }
      }
      $myItem['itemURL'] = $url;
      $myItem['itemTarget'] = $target;
      $myItem['itemLevel'] = 0;
      $title = '';
      if (isset($this->menuTitleField) && strlen($this->menuTitleField) > 0) {
        $title = htmlentities(stripslashes(trim($rs->Fields($this->menuTitleField))));
      }
      $myItem['itemTitle'] = $title;
      $pk = $rs->Fields($this->menuPK);
      $fk = (int)$rs->Fields($this->menuFK);
      $myArr = array();
      $myArr['data'] = $myItem;
      $this->DBItems[$fk][$pk] = $myArr;
      $rs->MoveNext();
    }
    if (!is_resource($this->query)) {
      $rs->MoveFirst();
    }
  }

  function _formatData ($key, $level, $maxLevel) {
    foreach ($this->DBItems[$key] as $pk => $value) {
      $value['data']['itemLevel'] = $level;
      array_push($this->menuItems, $value['data']);
      if (($maxLevel DBItems[$pk])) { // use $maxLevel only if positive
        $this->_formatData($pk, $level + 1, $maxLevel);
      }
    }
  }

}

{menu}

//CSSMenu1 Start   
  $CSSMenu1 = new MX_Menu('CSSMenu1');
  $CSSMenu1->setQuery($rsMenu);
  $CSSMenu1->setPK("content_id");
  $CSSMenu1->setFK("parent_id");
  $CSSMenu1->setNameField("menu_text");
  $CSSMenu1->setTitleField("");
//URL Type: Dynamic

  $CSSMenu1->setLinkField("content_alias");
  $CSSMenu1->setTargetField("");

//CSSMenu1 Layout
  $CSSMenu1->highlightCurrent(true);
  $CSSMenu1->setLevel(-1);
  $CSSMenu1->setLayout("horizontal");
  $CSSMenu1->setSkin("modern_red");
  $CSSMenu1->setShowTimeout(100);
  $CSSMenu1->setHideTimeout(400);
  $CSSMenu1->setImgReplace(false);
//CSSMenu1 End

and {menu_render}

//Dynamic CSS menu, Layout: horizontal, Skin: modern_red
  echo $CSSMenu1->render();


Hope this makes some sense.
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Interakt Menu Install

Post by Ted »

The problem is that plugins are separate functions.  So, the CSSMenu1 in {menu_render} has no clue about the CSSMenu1 in {menu}.  I would just put them all into one function instead.
cuhlcannon
Forum Members
Forum Members
Posts: 30
Joined: Wed Jun 22, 2005 8:02 am

Re: Interakt Menu Install

Post by cuhlcannon »

I added the two together, should I move the MX_menu class and functions all into the {menu} as well you think?

The error changed slightly, with the line number:

{/nocache:538d87d0148cd0f50b47c4893d4766cd#2}{nocache:538d87d0148cd0f50b47c4893d4766cd#3}
Fatal error: Call to a member function on a non-object in /hsphere/local/home/kevanarm/luxfer.biz/lib/content.functions.php(441) : eval()'d code on line 332
Ted
Power Poster
Power Poster
Posts: 3329
Joined: Fri Jun 11, 2004 6:58 pm

Re: Interakt Menu Install

Post by Ted »

Yup.  The 2nd function has no idea what a MX_menu is now.  :)
Post Reply

Return to “CMSMS Core”