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

Use PHP in Coldfusion? <cf_php>?

Guest
Jun 29, 2007 Jun 29, 2007
Greetings,

I am relatively new at CF and wish to use an existing PHP script I have (which highlights the current page tab on a CSS navbar, using a PHP include for the navbar) within the CFM file. I searched online and found an article that says this can supposedly be done by surrounding the PHP with <cf_php> tags Link to article. However, when I do this I get a processing error that says "Cannot find CFML template for custom tag php."

I would appreciate any suggestions or advice. Thanks for your help.
4.6K
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

Contributor , Jul 02, 2007 Jul 02, 2007
Ian Skinner has the answer for you, I've attached a more complete interpretation if you're interested. I've used the cfif tag but thats just a personal preference.

I would be more inclined to use a css class to set the style rather than setting the id but other than that it should be fine.

Translate
Explorer ,
Jun 29, 2007 Jun 29, 2007
Dixiedoo,

I think you need to download that scripting project before you can use it. Then, you would need to ensure that you have the php.cfm in your custom tags directory or in the local directory where you want to use it. Then you could use cf_php in your code.

Swift
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
LEGEND ,
Jun 29, 2007 Jun 29, 2007
dixiedoo wrote:
> Greetings,
>
> I am relatively new at CF and wish to use an existing PHP script I have (which
> highlights the current page tab on a CSS navbar, using a PHP include for the
> navbar) within the CFM file. I searched online and found an article that says
> this can supposedly be done by surrounding the PHP with <cf_php> tags
> http://scripting.riaforge.org/wiki/index.cfm/UsingPHPInColdFusion. However,
> when I do this I get a processing error that says "Cannot find CFML template
> for custom tag php."
>
> I would appreciate any suggestions or advice. Thanks for your help.
>

<cf_php...> is not part of native ColdFusion. Anything starting with
"cf_" is a custom tag developed to extend the capabilities of
ColdFusion. You need to get the custom tag code from that project site
and install it on your server to have access to its functionality.

You may want to read some of the documentation about installing, using
and creating custom tags. As a member is fond of saying, "If you don't
have a set, the internet does."

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
LEGEND ,
Jun 29, 2007 Jun 29, 2007
dixiedoo

I read a little deeper into that RIA project page. This custom tag may
only work on the newest version of ColdFusion, CF8 (Scorpio) currently
in beta. Just in case one was not aware of this.

Ian
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
Guest
Jun 29, 2007 Jun 29, 2007
also... are you running CF8?

the scripting library is CF8 only.
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
Guest
Jun 29, 2007 Jun 29, 2007
Greetings again,

I am running 7, not 8, so perhaps PHP cannot be incorporated? If not, can anyone point me to a way to highlight the current page on a navbar using Cold Fusion? I don't seem to be having luck finding such information (just more PHP methods : (

Thanks!
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
Guest
Jun 29, 2007 Jun 29, 2007
you're going to have to be a bit more specific. maybe show some code?

show what you have now (the navbar code), and indicate the condition that would determine which page is "highlighted" (and how it's highlighted).
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
LEGEND ,
Jun 30, 2007 Jun 30, 2007
In article <f63b48$9mf$1@forums.macromedia.com> Ian
Skinner<iskinner@cdpr.ca.gov> wrote:

> I read a little deeper into that RIA project page. This custom tag
> may only work on the newest version of ColdFusion, CF8 (Scorpio)
> currently in beta. Just in case one was not aware of this.

Technically, the custom tag relies on Java 6 which is why there is a
CF8 dependency - CF7 (and earlier) are not supported on Java 6.
Being even more pedantic, you can actually run the scripting project
on Java 5 if you find and download the javax.script.* package
implementation for Java 5. I haven't tried that.
You cannot run the scripting project on Java 1.4, however, because the
third party Java libraries that it relies on use features of Java not
present in Java 1.4.
If anyone has specific questions about the scripting project, feel
free to contact me off-list - sean@corfield.org. I plan to add more
languages to the project shortly.

--
I'm trying a new usenet client for Mac, Nemo OS X.
You can download it at http://www.malcom-mac.com/nemo

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
Contributor ,
Jul 01, 2007 Jul 01, 2007
Hi, how complex is the PHP in the navbar include and the highlighting code?

You'd probably be better off in the long run if you converted the scripts to ColdFusion/JavaScript rather than trying to find a way to interpret the existing code. Tasks such as navbar tab highlighting using CSS are best done in something like JavaScript, are you able to post some code samples?
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
Guest
Jul 02, 2007 Jul 02, 2007
Greetings,

I'm going to show some code. Nothing as of yet is in CF, but I plan to break down this simple page into CF header, footer, and nav includes before continuing on. Here is a link to the test page which currently uses the PHP highlight method: Link

I would highlight the current page navigation using CSS but that would require adding an ID to the body tag, which I don't want to do considering dynamic pages. PHP seemed like a good solution but not while using CF. I haven't been able to find a Javascript solution as of yet.

Thanks for all your help. Code follows:

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
Contributor ,
Jul 02, 2007 Jul 02, 2007
Ian Skinner has the answer for you, I've attached a more complete interpretation if you're interested. I've used the cfif tag but thats just a personal preference.

I would be more inclined to use a css class to set the style rather than setting the id but other than that it should be fine.

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
LEGEND ,
Jul 02, 2007 Jul 02, 2007
dixiedoo wrote:

> <div id="navContainer">
> <ul id="navbar">
> <li <?php if ($thisPage=="home")
> echo " id=\"currentpage\""; ?>><a href="index.cfm">home</a></li>
> <li <?php if ($thisPage=="authorities")
> echo " id=\"currentpage\""; ?>><a href="auth.cfm">authorities</a></li>
> <li <?php if ($thisPage=="contact")
> echo " id=\"currentpage\""; ?>><a href="contact.cfm">contact</a></li>
> <li <?php if ($thisPage=="contact type")
> echo " id=\"currentpage\""; ?>><a href="contype.cfm">contact
> type</a></li>
> </ul>
> </div>

Not big on my PHP but what I'm seeing there is the IIF() function in
ColdFusion.

<cfoutput>
<div id="navContainer">
<ul id="navbar">
<li #iif(thisPage EQ "home",DE('id="currentpage"'),DE(''))#><a
...></li>
...
</ul>
</div>
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
Guest
Jul 03, 2007 Jul 03, 2007
LATEST
That seems to work like a charm. Thanks so much!
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