Author Topic: menu with images?  (Read 1096 times)

Offline Roych

  • Betatester
  • **
  • Posts: 571
  • Gender: Male
menu with images?
« on: July 16, 2016, 03:16:32 PM »
Hello,
I'm trying to get images to my menu (flags) and I did so with a simple code, but the problem is that if there is no image in folder it shows me a litle no-image placeholder is it possible to get rid of this so that if there is no image it shows normal?


My code now is:
Code:
Only registered users can see contents. Please click here to Register or Login.

Or is there any better way to do this?


Thank you very much
R

Offline marmot

  • Posts: 1103
Re: menu with images?
« Reply #1 on: July 16, 2016, 06:52:32 PM »
Hi,

... if there is no image in folder it shows me a litle no-image placeholder is it possible to get rid of this so that if there is no image it shows normal?
I'm afraid showmenu can't do that. I guess the most easy thing would be to add blank images named by the menu title if there is no menu image available.

You can also patch showmenu2 to be more clever at this problem.
Or you can do some general replacement for all broken image links on a page by javascript, droplet or output filter.
For example if query is active on your page you can use
Code:
Only registered users can see contents. Please click here to Register or Login.
regards

Online jacobi22

  • Global Moderator
  • *****
  • Posts: 4678
  • Gender: Male
    • Jacobi22
Re: menu with images?
« Reply #2 on: July 17, 2016, 02:24:43 AM »
stackoverflow is your friend...

somewhere in the template-index.php a javascript-function like

define here your no-image-file (maybe a transparent gif with the same width&height?)
Code:
Only registered users can see contents. Please click here to Register or Login.
in the img-tag from $aItemOpen set a onerror like

Quote
$aItemOpen      = '<li class="[class] [if(class==menu-current){active}] [if(class==menu-expand){dropdown}]">[a]<div class="zastavice"><img src="http://riskchange.eu/site/templates/risk/menu_images/[menu_title].png" onerror="imgError(this);" class="zastavice2"/><>[menu_title]</a>',

it works fine, but in produce a network-error, because the show_menu2 calls also a missing image like a icon for page xyz, if there is no icon in the folder
                
Es bist immer nur Du, auch wenn du mich vergisst, es gibt niemanden, der mir näher ist
Immer nur du, die mich wach hält
(*miss you*)

Offline Roych

  • Betatester
  • **
  • Posts: 571
  • Gender: Male
Re: menu with images?
« Reply #3 on: July 17, 2016, 04:10:13 PM »
stackoverflow is your friend...

somewhere in the template-index.php a javascript-function like

define here your no-image-file (maybe a transparent gif with the same width&height?)
Code:
Only registered users can see contents. Please click here to Register or Login.
in the img-tag from $aItemOpen set a onerror like

Quote
$aItemOpen      = '<li class="[class] [if(class==menu-current){active}] [if(class==menu-expand){dropdown}]">[a]<div class="zastavice"><img src="http://riskchange.eu/site/templates/risk/menu_images/[menu_title].png" onerror="imgError(this);" class="zastavice2"/><>[menu_title]</a>',

it works fine, but in produce a network-error, because the show_menu2 calls also a missing image like a icon for page xyz, if there is no icon in the folder
               


Great one, works great, is there any way to get rid of this error maybe? It's not really a problem but, it's an error ...  ;D

Online jacobi22

  • Global Moderator
  • *****
  • Posts: 4678
  • Gender: Male
    • Jacobi22
Re: menu with images?
« Reply #4 on: July 18, 2016, 01:29:29 PM »
Quote
Great one, works great, is there any way to get rid of this error maybe? It's not really a problem but, it's an error ...

the answer is very easy: dont produce an error ;-)
from my point its not possible to set a "standard picture" (without an error) inside of the show_menu2 without a lot of changes in the include.php and in the core
Es bist immer nur Du, auch wenn du mich vergisst, es gibt niemanden, der mir näher ist
Immer nur du, die mich wach hält
(*miss you*)

Offline crnogorac081

  • Posts: 1848
  • Gender: Male
Re: menu with images?
« Reply #5 on: July 21, 2016, 02:13:41 AM »
Here is my suggestion

Code:
Only registered users can see contents. Please click here to Register or Login.
Images should be under ROOT/templates/risk/menu_images/bg-XXX.png where XXX is PAGE_ID number
no bb in signature