$5
Including two files using the TEMPLATHPATH approach
I imagine this is a very simple question (hence the $5 reward) but I can't quickly find the answer.
I'm using some if/then commands in my functions.php file to include files, using TEMPLATEPATH, depending on whether a person that fills out a form selects A, B or Both. If the person selects A, file A is included; if the person selects B, file B is included. So far so good. The code (which I think is using a Gravity Forms hook) looks a bit like this and works fine:
$cc_licences = $_POST["input_35"];
if($cc_licences == "Creative Commons Attribution-Non Commercial (CC BY-NC) licence"){ include( TEMPLATEPATH . '/files/cc_by_nc.php' );
}But if the person selects Both, I want to be able to include both file A and file B. So my question please is this: Is it possible to use the "include(TEMPLATEPATH . " approach and include two (or more) files rather than one? If so, can someone give me the sample code please?
Many thanks for your help. And thanks WPQuestions. A great service.
Richard
Richard | 07/01/10 at 6:09am
| Edit
(4) Possible Answers Submitted...
-

Last edited:
07/01/10
6:36amUtkarsh Kukreti says:include( TEMPLATEPATH . '/files/file1.php' );
include( TEMPLATEPATH . '/files/file2.php' );Previous versions of this answer: 07/01/10 at 6:12am
-

Last edited:
07/01/10
6:13am -
Last edited:
07/01/10
6:14am -

Last edited:
07/01/10
6:18amAgent Wordpress says:$cc_licences = $_POST["input_35"];
$cc_other = $_POST["something"];
if($cc_licences == "Creative Commons Attribution-Non Commercial (CC BY-NC) licence")
{
include( TEMPLATEPATH . '/files/file1.php' );
}
if($cc_other == "something else")
{
include( TEMPLATEPATH . '/files/file2.php' );
}
This way both files will be included if both conditions are true. But if only one of them is true, then only that file will be included.
(I have used dummy variable $cc_other for demonstration purpose)Previous versions of this answer: 07/01/10 at 6:18am
- 07/01/10 6:37am
Richard says:Thanks very much all. Much appreciate. I've chosen Uktarsh on a first answer first paid basis.
What a great service. I'm sure I'll be back with more questions.
Thanks again
Richard
- 07/01/10 6:37am
This question has expired.
Current status of this question: Completed




