[Register]
Powered by Elgg

Plugins :: Blog :: IsAdmin and a_href functions in a Plugin

July 02, 2007

Hi,

I just started to use elgg to build my new website and I'm developing a small "plugin" to build a menu to my site but I'm having some problems when I try to use the functions isadmin() and a_href. 

I found the code on /lib/elgglib.php and I see them being used everywhere (/lib/templates.php is a good example) but they just don't work when I call them in my plugin.

 Here is my code:

 

<?php
   

    function mainmenu_pagesetup() {
   
    }
   
    function mainmenu_init() {
       
        global $CFG;
        $CFG->templates->variables_substitute['mainmenu'][] = "mainmenu_main";
     }


   
    function mainmenu_main($vars) {
       
        global $CFG;
        global $profile_id;
        global $USER;


    if (isadmin()) {
       $menu_top = array( 'name' => 'admin',
                                    //'html' => a_href("{$CFG->wwwroot}_admin/",
                                    //                "Administration"));
                                    'html' =>"<a href=\"{$CFG->wwwroot}_admin/\">".__gettext("Administration")."</a>");
                                   
    }
   
    if (logged_on) {
        $menu_top= array(
                                 'name' => 'userdetails',
                                 //'html' => a_href("{$CFG->wwwroot}_userdetails/",
                                 //                  "Account settings"));
                                 'html' =>"<a href=\"{$CFG->wwwroot}_userdetails/\">".__gettext("My Account")."</a>");
       $menu_top = array(
                                 'name' => 'logoff',
                                 //'html' => a_href("{$CFG->wwwroot}login/logout.php",
                                 //                 "Log off"));
                                 'html' =>"<a href=\"{$CFG->wwwroot}login/logout.php\">".__gettext("Log off")."</a>");
    }
        $body = "";
    foreach($menu_top as $menu_top) {
        $body .= "<Table class=\"menu-table\"><tr><td style=\"color:#6c9c6e;\">&nbsp;".$menu_top->html."
                 &nbsp;|</td></tr></table>";
       
    }
       
        return $body;
       
    }

?>

 

Can anyone help me??

 

Thanks!!

Thiago Guerra 

Keywords: a_href, code, develop, href, isadmin, plugin

Posted by Thiago Guerra @ Plugins


Comments

  1. Hi, I´m working with ELGG too. Chulo

     I´d like create a plugin and looking your code i can see that you don´t use the method template_page_setup( )  (is in /lib/templates.php). This method up all the structure page and you should check this method ... Gui&ntilde;o

     I´ll see more about this...

    user icontreszero on Sunday, 08 July 2007, 04:17 UTC # |

You must be logged in to post a comment.

Site supported by Curverider Ltd - powered by the awesome Elgg