Welcome Guest, Not a member yet? Register   Sign In
my own helper creating menu
#14

[eluser]InsiteFX[/eluser]
1)For a helper like that you need to load it in your controller.
Your controller is the object.

If you need it across multiple controllers use a MY_Controller.

2) No you should not have html code in it unless you create.

3) A recursive function just calls itself.
Code:
function getChild($id)
        {
            $menu = "";
            $str = "";
            $s = "select id,title,parentid,link from ms_product where parentid = '$id' ";
            $res = $this->select_row($s);
            $menu .= '<div id="'.$id.'" style="display:none; position:absolute;">';
            $menu .= '<table border="1" cellspacing="0" cellpadding="0" style="border: 1px solid #FDCB55;  border-collapse:collapse;">';
            for ($i=0;$i<count($res);$i++)
            {
                $cnt_of_child = $this->recordCount("select id from ms_product where parentid = '".$res[$i][id]."' ");
                if ($cnt_of_child > 0)
                    $str = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="arrow_white.gif">';
                else
                    $str = " ";


                $menu .= '<tr height="20"><td align="left"  class="aerial12">';
                $menu .= '<div style="padding-left:10px;padding-right:5px; width:125px;" >';


                $menu .= $res[$i][title].$str;
                $menu .= '</div>';
                $menu .= '</td><td align="left" valign="top">';
                $menu .= $this->getChild($res[$i][id]);
                $menu .= '</td></tr>';
            }
            $menu .= '</table>';
            $menu .= '</div>';
            return $menu;
        }
See how getChild calls itself.

InsiteFX


Messages In This Thread
my own helper creating menu - by El Forum - 08-13-2011, 07:05 AM
my own helper creating menu - by El Forum - 08-13-2011, 10:37 AM
my own helper creating menu - by El Forum - 08-13-2011, 11:25 AM
my own helper creating menu - by El Forum - 08-13-2011, 12:04 PM
my own helper creating menu - by El Forum - 08-13-2011, 12:10 PM
my own helper creating menu - by El Forum - 08-13-2011, 12:14 PM
my own helper creating menu - by El Forum - 08-13-2011, 12:23 PM
my own helper creating menu - by El Forum - 08-13-2011, 12:42 PM
my own helper creating menu - by El Forum - 08-13-2011, 12:51 PM
my own helper creating menu - by El Forum - 08-13-2011, 01:17 PM
my own helper creating menu - by El Forum - 08-13-2011, 01:33 PM
my own helper creating menu - by El Forum - 08-13-2011, 07:06 PM
my own helper creating menu - by El Forum - 08-14-2011, 02:31 AM
my own helper creating menu - by El Forum - 08-14-2011, 04:04 AM
my own helper creating menu - by El Forum - 08-14-2011, 05:53 AM
my own helper creating menu - by El Forum - 08-14-2011, 06:28 AM
my own helper creating menu - by El Forum - 08-15-2011, 07:11 AM
my own helper creating menu - by El Forum - 08-15-2011, 07:34 AM
my own helper creating menu - by El Forum - 08-15-2011, 07:37 AM



Theme © iAndrew 2016 - Forum software by © MyBB