Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple menu question

New Here ,
Apr 29, 2009 Apr 29, 2009

I have a simple graphic menu with javascript mouseovers. I'm using cfinclude on all of my pages to include the menu. How do I get it to keep the mouseover graphic on that specific page. Is there a way to send a variable with cfinclude? Or should I be using a different tag?

1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Apr 29, 2009 Apr 29, 2009

URL variables do not make much sense.

I would normally just do something like this...

aPage.cfm

<cfset variables.thisPage = "aPage">

menuInclude.cfm

<cfif variables.thisPage = "aPage">

     <img src="/images/aPage.gif">

</cfelse>

     <a href="index.cfm"><img src="/images/a_home2.gif" onmouseout="SwapHome()" onmouseover="SwapHomeOver()" name="image1" / border="0"></a>

</cfif>

<cfif variables.thisPage = "bPage">

     <img src="/images/bPage.gif">

</cfelse>

     <a href="index.cfm"><img src="/images/b_home2.gi

...
Translate
Valorous Hero ,
Apr 29, 2009 Apr 29, 2009

There is nothing to send...

As the name indicates, <cfinclued....> literally included the code from the indicated file at the point of the tag.

Thus it is included in the same response and shares all variables available at that point in the code.

So this works just as you would expect it to.

main.cfm

<cfset variables.foobar = "Just for fun">

<cfinclude template = "another.cfm">

another.cfm

<cfoutput>#variables.foobar#</cfoutput>
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 29, 2009 Apr 29, 2009

I'm not sure what the scope of your project is, but it sounds as if it may be easier to simply have an index or main.cfm that already contains your menu, and then call your individual files via cfinclude.  That way, you wont have to include your menu on every page executed.

If you want your mouseover image to stick based on the page you are on, you will need write a statement surrounding your images that have a variable to check.

So example:

<cfif myPage EQ 2><img src="images/page2_mouseOver.gif"><cfelse><img src="images/page2.gif">

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2009 Apr 29, 2009

Right. So how do I send that variable to the menu?

Now the menu links just go to each page and each page has the menu included.

Example menu file included on each page:

<a href="index.cfm"><img src="/images/b_home2.gif"
onmouseout="SwapHome()" onmouseover="SwapHomeOver()" name="image1" / border="0"></a>

I could do that with a URL variable, right?

Change menu:

<a href="index.cfm?page=1"><cfif URL.page EQ 1><img src="/images/b_home3.gif"
onmouseout="SwapHome()" onmouseover="SwapHomeOver()" name="image1" / border="0"><cfelse><img src="/images/b_home2.gif"
onmouseout="SwapHome()" onmouseover="SwapHomeOver()" name="image1" / border="0"></cfif></a>

The problem is then I would have to add that variable to every link to every page.

Is there another way?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 29, 2009 Apr 29, 2009

URL variables do not make much sense.

I would normally just do something like this...

aPage.cfm

<cfset variables.thisPage = "aPage">

menuInclude.cfm

<cfif variables.thisPage = "aPage">

     <img src="/images/aPage.gif">

</cfelse>

     <a href="index.cfm"><img src="/images/a_home2.gif" onmouseout="SwapHome()" onmouseover="SwapHomeOver()" name="image1" / border="0"></a>

</cfif>

<cfif variables.thisPage = "bPage">

     <img src="/images/bPage.gif">

</cfelse>

     <a href="index.cfm"><img src="/images/b_home2.gif" onmouseout="SwapHome()" onmouseover="SwapHomeOver()" name="image2" / border="0"></a>

</cfif>

There are innumerable variations on this depending on how exactly you want your menu to work but this gives you the basic idea.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2009 Apr 29, 2009

That makes sense and is a whole lot easier.

Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 29, 2009 Apr 29, 2009

Now that we have showed you how simple it is to share data between a template and an included template.

You coud use getBaseTemplatePath() to do the same thing without requring anybody to set data in the code.

aPage.cfm

<cfinclude tempate="menu.cfm">

menu.cfm

<cfif listLast(getBaseTemplatePath(),"\") EQ "aPage.cfm">

<!--- listLast(getBaseTemplatePath(),"\") will return 'aPage.cfm" for the above code --->

   <img...>

<cfelse>

   <a...>

</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2009 May 06, 2009

So, I've finally got back around to trying the other way you suggested, and I can't seem to get it to work without using

<cfif #Right(listLast(getBaseTemplatePath()), 13)# EQ "contactus.cfm"> <img...> <cfelse> <a...> </cfif>

When I output listLast(getBaseTemplatePath()) it gives me the whole URL. Am I doing this wrong?

Thanks again for all of your help.

Date: Wed, 29 Apr 2009 10:32:23 -0600

From: forums@adobe.com

To: dooleymort@hotmail.com

Subject: Simple menu question

Now that we have showed you how simple it is to share data between a template in an included template.

You coud use getBaseTemplatePath() to do the same thing without requring anybody to set data in the code.

aPage.cfm

<cfinclude tempate="menu.cfm">

menu.cfm

<cfif listLast(getBaseTemplatePath()) EQ "aPage.cfm">

<!--- listLast(getBaseTemplatePath()) will return 'aPage.cfm" for the above code --->

<img...>

<cfelse>

<a...>

</cfif>

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 06, 2009 May 06, 2009
LATEST

Somehow I didn't include what I was using:

Right(listLast(getBaseTemplatePath()), 13) for contactus.cfm page

Date: Wed, 29 Apr 2009 10:32:23 -0600

From: forums@adobe.com

To: dooleymort@hotmail.com

Subject: Simple menu question

Now that we have showed you how simple it is to share data between a template in an included template.

You coud use getBaseTemplatePath() to do the same thing without requring anybody to set data in the code.

aPage.cfm

<cfinclude tempate="menu.cfm">

menu.cfm

<cfif listLast(getBaseTemplatePath()) EQ "aPage.cfm">

<!--- listLast(getBaseTemplatePath()) will return 'aPage.cfm" for the above code --->

<img...>

<cfelse>

<a...>

</cfif>

>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources