CGDevTools Forum

Welcome to the Official CGDevTools Support Community Forums.

Missing menu icons on most browsers

by kmccoy » 27 Aug 2013 20:02

I am building my menu programmatically, using the contents of a database table. This part works fine, but on most browsers (other than Firefox) a missing icon graphic appears on all sub-items. I have tried clearing menu item fields, adding a transparent icon, Etc., but I always get the missing graphic default icon. Everything works fine on Firefox.

Image


Here is the code... Any ideas?

Code: Select all
PROCEDURE TIWUserSession.PopulatePulldownMenu(mnu : TIWCGJQMenu; TableName : STRING; MenuID : Integer; CONST MenuClickHandler : TIWCGEvent);
// init a menu item node, using contents of database record
    FUNCTION miInit(mi : TIWCGJQMenuItem; Q : TQ; CONST MenuClick : TIWCGEvent) : Boolean;
    VAR
        miR : PMenuItemRec;
        slI,
        slO : Integer;
    BEGIN
        Result := FALSE;
        slO    := VDQ(Q, 'showifloggedout', 2);
        slI    := VDQ(Q, 'showifloggedin', 2);

        IF (UID = 0) THEN BEGIN
            IF slO = 0 THEN BEGIN
                mi.Free;  // hide item
                EXIT;
            END;
            mi.Disabled := slO < 2;
        END
        ELSE BEGIN
            IF slI = 0 THEN BEGIN
                mi.Free; // hide item
                EXIT;
            END;
            mi.Disabled := slI < 2;
        END;

        Result         := TRUE;
        GetMem(miR, SizeOf(TMenuItemRec));
        //        FillChar(miR, SizeOf(TMenuItemRec), #0);
        mi.Caption     := VDQ(Q, 'name', 'noname');
        mi.Hint        := VDQ(Q, 'hint', '');
        mi.Picture.Url := OrgDynamicDir + 'images/clear.gif';
        mi.Picture.UserCache := TRUE;
//        mi.Picture.Url := './images/clear.gif';
        mi.Picture.ImageIndex := -1;
        mi.Picture.Picture := nil;

        IF NOT mi.Disabled THEN BEGIN
            miR.URL := VDQ(Q, 'url', '');
            miR.ID  := VDQ(Q, 'id', 0);
        END;

        miR.ShowIfLoggedIn  := slI;  {TODO -oKevin -cToDo : This may not be needed}
        miR.ShowIfLoggedOut := slO;
        miR.FID             := VDQ(Q, 'fid', 0);  // frame ID to load if this menu item is clicked by user

        mi.UserData := miR;

        IF ((miR.FID <> 0) OR (miR.URL <> '')) AND (NOT mi.Disabled) THEN
            mi.OnClick.OnEvent := MenuClick
        ELSE
            mi.OnClick         := NIL;  // placeholder menu item - do not fire any click event if the user clicks on it
    END;

    // search nested menu items recursively, looking for ID
    FUNCTION RecursiveSearchParent(mi : TIWCGJQMenuItem; ID : Integer) : TIWCGJQMenuItem;
    VAR
        I :  Integer;
        Si : TIWCGJQMenuItem;
    BEGIN
        Result := NIL;
        IF PMenuItemRec(Mi.UserData).ID = ID THEN BEGIN
            Result := Mi;  // found the node we were looking for
            EXIT;
        END;
        FOR I := 0 TO Mi.SubItems.Count - 1 DO BEGIN     // if node has subnodes then search them too
            Si     := Mi.SubItems.Items[I];
            Result := RecursiveSearchParent(Si, ID);     // go to next level
            IF Result <> NIL THEN
                EXIT;
        END;
    END;

VAR
    Q :        TQ;
    I,
    J,
    ID,
    ParentID : Integer;
    mi,
    M :        TIWCGJQMenuItem;
    LastItem : STRING;
    Virgin :   Boolean;
BEGIN
    mnu.MenuItems.Clear;
    Q := TQ.Create;
    TRY
        Q.Add('select * from webpulldowns where menuid=:menuid order by parent,sortorder,name');
        Q.SVP('menuid', MenuID);

        Q.Open;

        WHILE NOT Q.EOF DO BEGIN
            ParentID := VDQ(Q, 'parent', 0);
            LastItem := VDQ(Q, 'name', 'unknown');
            IF ParentID = 0 THEN BEGIN
                                                    // new parent node (not child)
                miInit(mnu.MenuItems.Add, Q, NIL);  // no click handler on parents
            END
            ELSE BEGIN
                // find parent ID in list of existing menu items
                Virgin := TRUE;

                FOR I := 0 TO mnu.MenuItems.Count - 1 DO BEGIN                     // search top level nodes (parents)
                    M := RecursiveSearchParent(mnu.MenuItems.Items[I], ParentID);  // recursively search subnodes
                    IF M <> NIL THEN BEGIN
                        // found the parent, so add submenu item
                        miInit(M.SubItems.Add, Q, MenuClickHandler);
                        Virgin := FALSE;
                        Break;
                    END;
                END;

                //                IF Virgin THEN BEGIN
                //                    ID := VDQ(Q, 'id', 0);
                //                    RAISE EUnexpectedParams.CreateFmt('Orphaned webpulldown record; ID=%d; Name=%s', [ID, LastItem]);
                //                END;
            END;
            Q.Next;
        END;
    FINALLY
        Q.Free;
    END;
END;

Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

by Jorge Sousa » 27 Aug 2013 23:26

Hi

If it's IW14

in

mi.Picture.Url := OrgDynamicDir + 'images/clear.gif';

OrgDynamicDir must start with a '/'

You can see the urls that you set rendered in the browser? (inspecting element). When you hover the urls it's say 404? That's Intraweb not serving the image.

Regards

cgdevtools
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by kmccoy » 27 Aug 2013 23:34

I am using IW 12.2.20 and v1.7.0.2858.

Thanks for getting back to me. I will look at it later - I have a deadline to meet.
Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

by Jorge Sousa » 27 Aug 2013 23:42

Ok

But all it matters to us in this subject is the html that is rendered, because in this case the menu should render the img tag with the src attribute = mi.Picture.Url

Are you using ImageList, Actions or it's only direct urls?

Regards

cg st
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58

by kmccoy » 27 Aug 2013 23:46

Direct URLs for the icons - the graphics are actually on another server, so I had to use fully qualified URLs. I think this was confusing things. I noticed that a "/" was prepended automatically if I used a relative URL. I still couldn't get it to work though :)

The basic problem was that the menu items showed a broken icon even if I did not want graphics at all. I was trying to work around that by using a completely transparent icon.
Best Regards,

Kevin G. McCoy
kmccoy
 
Posts: 90
Joined: 08 Oct 2012 13:01

by Jorge Sousa » 28 Aug 2013 00:02

Hi

For empty icons you just need to set Url = '' (with no ImageLists)

it uses '/css/blank.gif' internally

i hope you didn't forgot to update the wwwroot, it happens to us sometimes.

Regards

cgdevtools st
Best Regards
CGDevTools Develop / Support Team
Home Page: http://www.cgdevtools.com
Jorge Sousa
 
Posts: 4261
Joined: 17 May 2012 09:58


Return to JQMenu

cron

Who is online

Users browsing this forum: No registered users and 1 guest

Contact Us.