1
juanjo
How to add SmartyMenu to Xoops?
  • 2005/5/1 15:23

  • juanjo

  • Just popping in

  • Posts: 18

  • Since: 2005/3/20


Hi all xoopsers!!
I am trying to make SmartyMenu (http://www.phpinsider.com/php/code/SmartyMenu/) work in my (xoops) site (but of course I couldn't, that's why I'm writing here... :P )
I thought the best option would be to insert the SmartyMenu code in the theme.html webpage. But (opposite to what the author of SmartyMenu suggests) I am not familiar enough with Smarty templating language.
I have tried to call a php file I generated (by means of a <?php require('filename.php')?>) from the theme.html, but theme.html does not have any php code at all!!
How could I insert the SmartyMenu code in my web page?
- I have put the Smarty functions and plugins where it is said to do so
- I would like to have this dropdown menu in EVERY page that is loaded, that is why I thought as a good option having the SmartyMenu called from (my) theme.html
Any help will be greatly appreciated!
Juan J

2
-DJNZ-
Re: How to add SmartyMenu to Xoops?
  • 2005/5/1 15:54

  • -DJNZ-

  • Just popping in

  • Posts: 30

  • Since: 2005/1/11


Quote:

juanjo wrote:
...theme.html does not have any php code at all!!

No, the whole point of using Smarty is that template files do not need PHP in them. But to do something like you want, it is possible to put PHP in a template as below - put this somewhere near the beginning of theme.html (just after the <html> tag would do). But IMHO this is not a very efficient way of putting a static menu on your site: there are just too many calls to SmartyMenu methods. If I was writing SmartyMenu I would have used an array for input.
<{php}>
    require_once(
'/path/to/where/you/put/it/SmartyMenu.class.php');
   
    
// initialize your menu
    
SmartyMenu::initMenu($menu);

    
// first menu item
    
SmartyMenu::initItem($item);
    
SmartyMenu::setItemText($item'Yahoo');
    
SmartyMenu::setItemLink($item'http://www.yahoo.com/');
    
SmartyMenu::addMenuItem($menu$item);
...    
    
$this->assign('smarty_menu'$menu); // for PHP code in a template the Smarty object is in $this
<{/php}>

Then you can just put <{$smarty_menu}> in the template where you want it to appear. Don't forget to put the link to the CSS file in <head> too.

3
juanjo
Re: How to add SmartyMenu to Xoops?
  • 2005/5/1 17:51

  • juanjo

  • Just popping in

  • Posts: 18

  • Since: 2005/3/20


Thanks!
It did work perfect. I just had to change
<{menu data=$smarty_menu}>

instead of
<{$smarty_menu}>

and voila!!
Thank you very much!!
PS: there is an array'ed way to do the menus with Smarty also, but I just wanted to have anything that worked and then decide what option to implement.

4
-DJNZ-
Re: How to add SmartyMenu to Xoops?
  • 2005/5/2 1:42

  • -DJNZ-

  • Just popping in

  • Posts: 30

  • Since: 2005/1/11


Quote:

PS: there is an array'ed way to do the menus with Smarty also...

Thanks, I missed that when I read the info. And I got the other thing wrong too - well, I am glad it worked!

Login

Who's Online

174 user(s) are online (127 user(s) are browsing Support Forums)


Members: 0


Guests: 174


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits