I'm trying to edit my primary links menu to replace the text with a button image, and I'm having a problem with getting my <img> tag to display. I've overridden the theme_menu_links() function in template.php, and it looks like what I need to do is replace $link['title'] with the <img> tag. To do this, I added this line to the function:
$link['title'] = "<img src="images/btn_home.jpg">";
However, the whole tag is displayed as text on the page, and when I view source, this is what I see for the link:
<li><a href="/drupal57/" title="Home page" class="active"><img src='images/btn_home.jpg'></a></li>
I don't understand this, because in other places in the function, that is how tags are written out in the code. What do I need to change to get the actual quotes and < > symbols written out correctly?
Thanks.
Steve
While this isn't exactly the answer to your question, which I see that you found on your own. I would definitely recommend doing the image replacement via CSS, so that print and screen reading versions of your site don't have any loss of experience. In my experience this also is better for browsers that have images turned off as well.
-Mikey P
On Mar 23, 2008, at 2:26 PM, Steve Edwards wrote:
I'm trying to edit my primary links menu to replace the text with a button image, and I'm having a problem with getting my <img> tag to display. I've overridden the theme_menu_links() function in template.php, and it looks like what I need to do is replace $link['title'] with the <img> tag. To do this, I added this line to the function:
$link['title'] = "<img src="images/btn_home.jpg">";
However, the whole tag is displayed as text on the page, and when I view source, this is what I see for the link:
<li><a href="/drupal57/" title="Home page" class="active"><img src='images/btn_home.jpg'></a></li>
I don't understand this, because in other places in the function, that is how tags are written out in the code. What do I need to change to get the actual quotes and < > symbols written out correctly?
Thanks.
Steve
[ Drupal support list | http://lists.drupal.org/ ]
__________________ Michael Prasuhn mike@mikeyp.net http://mikeyp.net 949.200.7595 714.356.0168 cell 949.200.7670 fax
I tried doing that, but I haven't had any luck with that. Would I use the background-image property for the list item? Or is there a better property to use?
Steve
Michael Prasuhn wrote:
While this isn't exactly the answer to your question, which I see that you found on your own. I would definitely recommend doing the image replacement via CSS, so that print and screen reading versions of your site don't have any loss of experience. In my experience this also is better for browsers that have images turned off as well.
-Mikey P
On Mar 23, 2008, at 2:26 PM, Steve Edwards wrote:
I'm trying to edit my primary links menu to replace the text with a button image, and I'm having a problem with getting my <img> tag to display. I've overridden the theme_menu_links() function in template.php, and it looks like what I need to do is replace $link['title'] with the <img> tag. To do this, I added this line to the function:
$link['title'] = "<img src="images/btn_home.jpg">";
However, the whole tag is displayed as text on the page, and when I view source, this is what I see for the link:
<li><a href="/drupal57/" title="Home page" class="active"><img src='images/btn_home.jpg'></a></li>
I don't understand this, because in other places in the function, that is how tags are written out in the code. What do I need to change to get the actual quotes and < > symbols written out correctly?
Thanks.
Steve
[ Drupal support list | http://lists.drupal.org/ ]
Michael Prasuhn mike@mikeyp.net http://mikeyp.net 949.200.7595 714.356.0168 cell 949.200.7670 fax
use theme_image to create your image source. For the path, use path_to_theme() . "/images/yourimage.png"
Another option entirely, is to create your own theming function. I like to do this when I have a totally separate primary links section.
themename_do_my_links($links) { ... }
then in page.tpl.php file use theme("do_my_links", $primary_links) for the main nav items
This makes it easy to separate display of your primary links with any other menus you have.
On Mon, Mar 24, 2008 at 10:25 AM, Steve Edwards killshot91@comcast.net wrote:
I tried doing that, but I haven't had any luck with that. Would I use the background-image property for the list item? Or is there a better property to use?
Steve
Michael Prasuhn wrote:
While this isn't exactly the answer to your question, which I see that you found on your own. I would definitely recommend doing the image replacement via CSS, so that print and screen reading versions of your site don't have any loss of experience. In my experience this also is better for browsers that have images turned off as well.
-Mikey P
On Mar 23, 2008, at 2:26 PM, Steve Edwards wrote:
I'm trying to edit my primary links menu to replace the text with a button image, and I'm having a problem with getting my <img> tag to display. I've overridden the theme_menu_links() function in template.php, and it looks like what I need to do is replace $link['title'] with the <img> tag. To do this, I added this line to the function:
$link['title'] = "<img src="images/btn_home.jpg">";
However, the whole tag is displayed as text on the page, and when I view source, this is what I see for the link:
<li><a href="/drupal57/" title="Home page" class="active"><img src='images/btn_home.jpg'></a></li>
I don't understand this, because in other places in the function, that is how tags are written out in the code. What do I need to change to get the actual quotes and < > symbols written out correctly?
Thanks.
Steve
[ Drupal support list | http://lists.drupal.org/ ]
Michael Prasuhn mike@mikeyp.net http://mikeyp.net 949.200.7595 714.356.0168 cell 949.200.7670 fax
-- [ Drupal support list | http://lists.drupal.org/ ]
Actually, that's what I did. I put a copy of theme_menu_links() in template.php and renamed it to mytheme_menu_links(), and then in page.tpl.php I changed it to
theme('menu_links', $primary_links);
and that's worked pretty well. Now all I have to do is get a mouseover effect to work and get the images aligned properly.
If anybody is curious to see this and has any suggestions, I'm working on the page at http://dev.capusfiresafety.org (Drupal), and trying to get it to look like http://www.campusfiresafety.org (non-Drupal).
Thanks.
Steve
Eric McKenna wrote:
use theme_image to create your image source. For the path, use path_to_theme() . "/images/yourimage.png"
Another option entirely, is to create your own theming function. I like to do this when I have a totally separate primary links section.
themename_do_my_links($links) { ... }
then in page.tpl.php file use theme("do_my_links", $primary_links) for the main nav items
This makes it easy to separate display of your primary links with any other menus you have.
On Mon, Mar 24, 2008 at 10:25 AM, Steve Edwards killshot91@comcast.net wrote:
I tried doing that, but I haven't had any luck with that. Would I use the background-image property for the list item? Or is there a better property to use?
Steve
Michael Prasuhn wrote:
While this isn't exactly the answer to your question, which I see that you found on your own. I would definitely recommend doing the image replacement via CSS, so that print and screen reading versions of your site don't have any loss of experience. In my experience this also is better for browsers that have images turned off as well.
-Mikey P
On Mar 23, 2008, at 2:26 PM, Steve Edwards wrote:
I'm trying to edit my primary links menu to replace the text with a button image, and I'm having a problem with getting my <img> tag to display. I've overridden the theme_menu_links() function in template.php, and it looks like what I need to do is replace $link['title'] with the <img> tag. To do this, I added this line to the function:
$link['title'] = "<img src="images/btn_home.jpg">";
However, the whole tag is displayed as text on the page, and when I view source, this is what I see for the link:
<li><a href="/drupal57/" title="Home page" class="active"><img src='images/btn_home.jpg'></a></li>
I don't understand this, because in other places in the function, that is how tags are written out in the code. What do I need to change to get the actual quotes and < > symbols written out correctly?
Thanks.
Steve
[ Drupal support list | http://lists.drupal.org/ ]
Michael Prasuhn mike@mikeyp.net http://mikeyp.net 949.200.7595 714.356.0168 cell 949.200.7670 fax
-- [ Drupal support list | http://lists.drupal.org/ ]