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

creating a tag using "pageType eq" work for 2 page titles instead of one

Contributor ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

I have code in my application that is working via different directories. The page with the code is in a directory called cf and there are pages in a different directory that need to use the same code. right now it is set up like this:

<cfif pageType eq "events">
they get this code
<cfelse>
they get this code
</cfif>

I need it to do something like this:

<cfif pageType eq "events" OR "news">
they get this code
<cfelse>
they get this code
</cfif>

When I write it like this, I get an error about not being able to convert it to boleen code.

Is there and easier way to do this?
Thank you.

Phoenix
TOPICS
Advanced techniques

Views

266

Translate

Translate

Report

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

Advocate , Apr 03, 2007 Apr 03, 2007
Azadi's solution is probably going to be your best bet for maintainability, especially if you are going to have a bunch of pageType's you want to check. You should be able to combine the news and events case into 1 <cfcase> tag:

<cfswitch expression="#pageType#">
<cfcase value="news,events">
they get news and events code
</cfcase>
<cfdefaultcase>
they get other code
</cfdefaultcase>
</cfswitch>

Votes

Translate

Translate
LEGEND ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

> <cfif pageType eq "events" OR "news">

has to be <cfif pageType eq "events" OR pageType eq "news">

you probably better use <cfswitch>/<cfcase> construct instead:
<cfswitch expression="#pageType#">
<cfcase value="news">
they get news code
</cfcase>
<cfcase value="events">
they get events code
</cfcase>
</cfswitch>

depending on your version of cf you may or may not have to put in
<cfdefaultcase> inside <cfswitch> as well...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

Votes

Translate

Translate

Report

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
Engaged ,
Apr 02, 2007 Apr 02, 2007

Copy link to clipboard

Copied

Just looking at your code, I see a potential reason with your CFIF tag.

Should Be
<cfif pageType eq "events" OR pageType eq "news">
they get this code
<cfelse>
they get this code
</cfif>

Votes

Translate

Translate

Report

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
Advocate ,
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

Azadi's solution is probably going to be your best bet for maintainability, especially if you are going to have a bunch of pageType's you want to check. You should be able to combine the news and events case into 1 <cfcase> tag:

<cfswitch expression="#pageType#">
<cfcase value="news,events">
they get news and events code
</cfcase>
<cfdefaultcase>
they get other code
</cfdefaultcase>
</cfswitch>

Votes

Translate

Translate

Report

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
Contributor ,
Apr 03, 2007 Apr 03, 2007

Copy link to clipboard

Copied

LATEST
Thank you for all the help!

Votes

Translate

Translate

Report

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
Documentation