Top level menu items as images

Posted By saturation Tue 3 May 2011
Add to Favorites0
Author Message
saturation
 Posted Tue 3 May 2011
Supreme Being

Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)Supreme Being - (64,938 reputation)

Group: Forum Members
Last Active: Fri 30 Nov 2012
Posts: 108, Visits: 1,185
Does anyone have any advice or suggestions on how to use images instead of text as the top level menus?
Mohammad
 Posted Wed 4 May 2011
Kartris Expert

Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)Kartris Expert - (78,885 reputation)

Group: Administrators
Last Active: Sun 27 Sep 2015
Posts: 115, Visits: 706
If you are using Kartris v1.3 (because the code is partially opened) then you can apply the below:

1. Go to UserControls > Skin > CategoryMenu.ascx.vb
2. Add the following lines as last lines of the 'menCategory_MenuItemDataBound' event (just before End Sub):
Dim strImagePath As String = GetImagePath(CType(e.Item.DataItem, SiteMapNode).Key)
If strImagePath IsNot Nothing Then
  e.Item.ImageUrl = strImagePath
  e.Item.Text = ""
End If

3. Add the following function in the same page:
Function GetImagePath(ByVal strKey As String) As String
Dim arrKeys() As String = strKey.Split(",")
If arrKeys.Length > 2 Then Return Nothing
Dim strFolderPath As String = _
Kartris.CkartrisImages.strCategoryImagesPath & "/" & arrKeys(1) & "/"
If Not Directory.Exists(Server.MapPath(strFolderPath)) Then Return Nothing
Dim dirFolder As New DirectoryInfo(Server.MapPath(strFolderPath))
If dirFolder.GetFiles().Length < 1 Then Return Nothing
Return CkartrisBLL.WebShopURL & "Image.aspx?strFileName=" & dirFolder.GetFiles()(0).Name & _
"&amp;strItemType=c&amp;numMaxHeight=" & _
KartSettingsManager.GetKartConfig("frontend.display.images.minithumb.height") & _
"&amp;numMaxWidth=" & _
KartSettingsManager.GetKartConfig("frontend.display.images.minithumb.width") & _
"&amp;numItem=" & arrKeys(1) & "&amp;strParent=0"
End Function

Above code, will show the image of the category (if its top level one) and removes the name of the category.

If the image(s) didn't appear, you need to wait for a while or restart the application, cause the category menu is using the output cache.
Wed 4 May 2011 by Mohammad

Similar Topics

Expand / Collapse

Reading This Topic

Expand / Collapse

Back To Top