Posts: 28
Threads: 4
Joined: Aug 2014
Hello,
I'm using I18N menus and would like to be able to use unique images rather than text for my menus or a default background image and the I18N menu text in front.
Can someone help me with this please?
As an enhancement it would be great to be able to either select and menu image and/or menu text for each page??
Many thanks
Guy
Posts: 2,094
Threads: 54
Joined: Jan 2011
(2014-08-28, 00:41:04)GuyB Wrote: I'm using I18N menus and would like to be able to use unique images rather than text for my menus or a default background image and the I18N menu text in front.
You can use the I18N Custom Fields plugin, define an image field for the menu image and then use custom rendering.
Posts: 28
Threads: 4
Joined: Aug 2014
Hello Mvlcek,
Thanks for your prompt reply, I'll try it out.
Regards
Guy
Posts: 28
Threads: 4
Joined: Aug 2014
(2014-08-28, 04:04:01)GuyB Wrote: Hello Mvlcek,
Thanks for your prompt reply, I'll try it out.
Regards
Guy
Hello Mvlcek,
I've tried this and am struggling! this is what I have done..
I've created a custom field called MenuImage and set up a default image.
I've created a component called navimage with this in it:
<li class="<?php echo $item->classes; ?>">
<a href="<?php echo htmlspecialchars($item->link); ?>">
<?php echo htmlspecialchars($item->text); ?>
</a>
<?php if ($item->isOpen) { ?>
<ul><?php $item->menuimage(); ?></ul>
<?php } ?>
</li>
I've altered my template.php to this:
<ul><?php get_i18n_navigation(return_page_slug(),0,100,navimage); ?></ul>
And I keep getting error:
Notice: Use of undefined constant navimage - assumed 'navimage' in C:\vhosts
It looks I've either got the syntax wrong or the custom field isn't working correctly - any advice would be very helpful
Thanks
Guy
Posts: 1,129
Threads: 137
Joined: Feb 2012
Hi Guy this isn't what you asked exactly I know but I'll mention it anyway. I had to do something like that here:
http://www.janetphillips-weaving.co.uk/
where each menu item has a different image of fabric. It isn't done with I18N although the site does have two levels of navigation. The selection of background images in the menu items is just done with css using the page slug as a selector.
I put the theme I made for that purpose in extend in two versions with the same code, just different fonts and images as 'green clock' and 'catwalk'. Feel free to unpick it and reuse if it's any help to you. If it isn't clear how it works then ask and I will see if I can remember.[/align]
Posts: 28
Threads: 4
Joined: Aug 2014
(2014-08-28, 06:44:48)Timbow Wrote: Hi Guy this isn't what you asked exactly I know but I'll mention it anyway. I had to do something like that here:
http://www.janetphillips-weaving.co.uk/
where each menu item has a different image of fabric. It isn't done with I18N although the site does have two levels of navigation. The selection of background images in the menu items is just done with css using the page slug as a selector.
I put the theme I made for that purpose in extend in two versions with the same code, just different fonts and images as 'green clock' and 'catwalk'. Feel free to unpick it and reuse if it's any help to you. If it isn't clear how it works then ask and I will see if I can remember.[/align] Hello Timbow,
Yes that would do the trick for me, how did you do that?
Thanks
Guy
Posts: 2,094
Threads: 54
Joined: Jan 2011
2014-08-28, 07:40:02
(This post was last modified: 2014-08-28, 07:41:29 by mvlcek.)
(2014-08-28, 05:37:34)GuyB Wrote: I've tried this and am struggling! this is what I have done..
I've created a custom field called MenuImage and set up a default image.
I've created a component called navimage with this in it:
<li class="<?php echo $item->classes; ?>">
<a href="<?php echo htmlspecialchars($item->link); ?>">
<?php echo htmlspecialchars($item->text); ?>
</a>
<?php if ($item->isOpen) { ?>
<ul><?php $item->menuimage(); ?></ul>
<?php } ?>
</li>
I've altered my template.php to this:
<ul><?php get_i18n_navigation(return_page_slug(),0,100,navimage); ?></ul>
hanks
Guy
Remove the parentheses:
Code: <?php $item->menuimage; ?>
(and you need to add the image tag <img ...>, as above code only returns the link, if it's an image field)
Add quotes:
Code: <?php get_i18n_navigation(return_page_slug(),0,100,'navimage'); ?>
Posts: 1,129
Threads: 137
Joined: Feb 2012
For simple menu items with different background images. This line of css will give a default background image to menu items:
Code: nav a {background-image:url(images/menuimg01.png);}
then for specific images for specific pages:
Code: nav a[href*="about"] {background-image:url(images/menuimg02.png);}
Which says (in english) Quote:for anchor elements which are children of nav, if the href contains the text "about" then the background image is menuimg02.png
Posts: 28
Threads: 4
Joined: Aug 2014
2014-08-28, 17:45:02
(This post was last modified: 2014-08-28, 17:45:52 by GuyB.)
(2014-08-28, 07:40:02)mvlcek Wrote: (2014-08-28, 05:37:34)GuyB Wrote: I've tried this and am struggling! this is what I have done..
I've created a custom field called MenuImage and set up a default image.
I've created a component called navimage with this in it:
<li class="<?php echo $item->classes; ?>">
<a href="<?php echo htmlspecialchars($item->link); ?>">
<?php echo htmlspecialchars($item->text); ?>
</a>
<?php if ($item->isOpen) { ?>
<ul><?php $item->menuimage(); ?></ul>
<?php } ?>
</li>
I've altered my template.php to this:
<ul><?php get_i18n_navigation(return_page_slug(),0,100,navimage); ?></ul>
hanks
Guy
Remove the parentheses:
Code: <?php $item->menuimage; ?>
(and you need to add the image tag <img ...>, as above code only returns the link, if it's an image field)
Add quotes:
Code: <?php get_i18n_navigation(return_page_slug(),0,100,'navimage'); ?>
Hello Mwlcek,
Can you explain that please about the image tag?
Thanks
Guy
(2014-08-28, 10:14:26)Timbow Wrote: For simple menu items with different background images. This line of css will give a default background image to menu items:
Code: nav a {background-image:url(images/menuimg01.png);}
then for specific images for specific pages:
Code: nav a[href*="about"] {background-image:url(images/menuimg02.png);}
Which says (in english) Quote:for anchor elements which are children of nav, if the href contains the text "about" then the background image is menuimg02.png Thanks very much Timbow,
That seems understandable.
Regards
Guy
Posts: 28
Threads: 4
Joined: Aug 2014
(2014-08-28, 17:45:02)GuyB Wrote: (2014-08-28, 07:40:02)mvlcek Wrote: (2014-08-28, 05:37:34)GuyB Wrote: I've tried this and am struggling! this is what I have done..
I've created a custom field called MenuImage and set up a default image.
I've created a component called navimage with this in it:
<li class="<?php echo $item->classes; ?>">
<a href="<?php echo htmlspecialchars($item->link); ?>">
<?php echo htmlspecialchars($item->text); ?>
</a>
<?php if ($item->isOpen) { ?>
<ul><?php $item->menuimage(); ?></ul>
<?php } ?>
</li>
I've altered my template.php to this:
<ul><?php get_i18n_navigation(return_page_slug(),0,100,navimage); ?></ul>
hanks
Guy
Remove the parentheses:
Code: <?php $item->menuimage; ?>
(and you need to add the image tag <img ...>, as above code only returns the link, if it's an image field)
Add quotes:
Code: <?php get_i18n_navigation(return_page_slug(),0,100,'navimage'); ?>
Hello Mwlcek,
Can you explain that please about the image tag?
Thanks
Guy
(2014-08-28, 10:14:26)Timbow Wrote: For simple menu items with different background images. This line of css will give a default background image to menu items:
Code: nav a {background-image:url(images/menuimg01.png);}
then for specific images for specific pages:
Code: nav a[href*="about"] {background-image:url(images/menuimg02.png);}
Which says (in english) Quote:for anchor elements which are children of nav, if the href contains the text "about" then the background image is menuimg02.png Thanks very much Timbow,
That seems understandable.
Regards
Guy Hello Mwlcek,
Can you explain about the image tag please?
Thanks
Guy
Posts: 2,094
Threads: 54
Joined: Jan 2011
(2014-09-01, 05:16:08)GuyB Wrote: Can you explain about the image tag please?
Code: <img src="<?php echo htmlspecialchars($item->menuimage); ?>"/>
Posts: 11
Threads: 0
Joined: Dec 2013
And... what if I want to put a glyphicon instead of a image???? Diferent Glyphicons for every menu item...
|