Easy way to replace navigation menu text links with images?

rated by 0 users
This post has 10 Replies | 6 Followers

Not Ranked
Posts 26
Points 400
chrisrsimons Posted: Wed, Apr 25 2007 3:13 PM

Is there an easy way in CS 2007 that I could replace text within each navigation menu item with an image of my choosing?  To further add onHover and onClick actions to the image would also be a plus.

Any suggestions?? Smile 

Thank you.  Beer

  • | Post Points: 35
Top 25 Contributor
Posts 867
Points 13,470

Hi Chris,

You can do all this in CS 2007, much easier than it was in previous versions, but it will take a bit of time to create a new theme.  I suggest copying an existing theme that you like to a new folder and then modifying it.  There are other posts about how to get started with this.  You'll need to know HTML, XML, and how to use the new controls on Chameleon (the new theme engine).  Almost all of the text for the site is in XML resource files, but you can also hard code text if you really want to.

Take it easy,
Bill

WGB Enterprises - Freelance Community Server and other Development
openSourceC.org

  • | Post Points: 5
Top 10 Contributor
Posts 2,423
Points 19,635
MVPs
Nick replied on Thu, Apr 26 2007 7:41 AM

 Find the navigation controls, and add a <itemtemplate><img src="../imagehandler.ashx?text=<%#Eval("Text")%>" alt="<%#Eval("Text")%>" /></itemtemplate>

  • | Post Points: 20
Top 50 Contributor
Posts 353
Points 5,140
Tabs replied on Mon, Apr 30 2007 3:14 PM

Nick:

 Find the navigation controls, and add a <itemtemplate><img src="../imagehandler.ashx?text=<%#Eval("Text")%>" alt="<%#Eval("Text")%>" /></itemtemplate>

 

For those of us less fortunate (read: basically know bugger all about programming Big Smile ) how does this work? Where is the code inserted and where do we place/ store the images to be used? Presumably in the common images directory?

My wild guess says text=<%#Eval("Text")%> refers to the xml text it should look for to replace with alt=<%#Eval("Text")%> (with alt being the path to the image file swap out with)? Or am I barking up the wrong tree?

I'm trying to use basic images for the navigation, nothing as extravagant as what the OP wants to do, but the principal is still the same.

Any help would be appreciated here. I'm itching to get a site theme knocked up....

  • | Post Points: 20
Top 10 Contributor
Posts 2,423
Points 19,635
MVPs
Nick replied on Mon, Apr 30 2007 3:21 PM

O, if u wanted it like that:

<itemtemplate><img src="/themes/.../images/<%#Eval("Name")%>.gif" alt="<%#Eval("Text")%>" /></itemtemplate>

  • | Post Points: 20
Top 50 Contributor
Posts 353
Points 5,140
Tabs replied on Tue, May 1 2007 6:05 AM

Thanks, I'm still none the wiser though. You ever thought about writing crossword clues for a living? Stick out tongue

Care to elaborate on the code above? What do the "Name" and "Text" items in the template relate to? 


 

  • | Post Points: 20
Top 10 Contributor
Posts 2,423
Points 19,635
MVPs
Nick replied on Tue, May 1 2007 11:02 AM

name relates to the name attribute of the site url in the siteurls.config file.  Text represents the text that it puts out.  Usually name doesn't have spaces, or case sensitivity in it

  • | Post Points: 20
Top 50 Contributor
Posts 353
Points 5,140
Tabs replied on Tue, May 1 2007 1:24 PM

Tar mucka, will have a fiddle (with the code).

  • | Post Points: 20
Not Ranked
Posts 8
Points 145
ldaknis replied on Mon, Jun 2 2008 4:02 PM

I have implemented this successfully, but even though the images appear, they are no longer links.

Any ideas?

  • | Post Points: 20
Not Ranked
Posts 42
Points 555

also with this you lose the "selected" aspect ....i want to be able to show a color difeffernce for the tabs .... so it should look like

 

<ul id="nav">

<li id="home" class="selected"><a href="">home</a></li>

<li id="forum"><a href="forurms">forums</a></li>

then set the text-indent to -10000 and a background image on the li.....how do i do this?

 

  • | Post Points: 20
Top 10 Contributor
Posts 3,323
Points 73,040
MVPs

Beer,

In my CS experiences, some times it's easier to rip out the component you want to change and insert your own.  For the menu in CS2007, you could build your own by simply substituting your spiffy graphical menu for the location the CS menu is located.  For CS2007 this would be in \themes\yourtheme\common\Master.master and look like this.

         <CSControl:NavigationList runat="server" Tag="div" CssClass="CommonTabBarInner">
                                    <HeaderTemplate><table cellspacing="0" cellpadding="0" border="0"><tr valign="middle"></HeaderTemplate>
                                    <ItemTemplate>
                                        <CSControl:CSLinkData runat="server" Tag="Td" CssClass="CommonSimpleTabStripSelectedTab" onmouseover="tabOver(this);" onmouseout="tabOut(this);" LinkTo="Link" Property="Text">
                                            <DisplayConditions><CSControl:CSLinkPropertyValueComparison runat="server" ComparisonProperty="IsSelected" Operator="IsSetOrTrue" /></DisplayConditions>
                                        </CSControl:CSLinkData>
                                        <CSControl:CSLinkData runat="server" Tag="Td" CssClass="CommonSimpleTabStripTab" onmouseover="tabOver(this);" onmouseout="tabOut(this);" LinkTo="Link" Property="Text">
                                            <DisplayConditions Operator="Not"><CSControl:CSLinkPropertyValueComparison runat="server" ComparisonProperty="IsSelected" Operator="IsSetOrTrue" /></DisplayConditions>
                                        </CSControl:CSLinkData>
                                    </ItemTemplate>
                                    <FooterTemplate></tr></table></FooterTemplate>
                                </CSControl:NavigationList>

Replace that with your menu and you should be a happy image menubar camper.

Regards,
Dave

 

  • | Post Points: 5
Page 1 of 1 (11 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com