CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 include custom code

Print topic Send  topic

Author Message
krmk
Posted: 03/26/2004, 4:33 AM

I am trying to include a custom code snippet (a simple "Hello world" snippet) in a spesific place in default.php which is created by ccs. I placed a custom variable {myvar} in default.php, then I put a code in Page/Before Show event like that:

global $Tpl;
$fcontents = join ('', file ('customcode.php'));
$Tpl->SetVar("myvar",$fcontents); 

The customcode.php was assigned to myvar but as a text file and not executed as php file. The html code was like this:

<table width="100%" border="1">
<tr>
<td><?php
echo "hello world";
?>
</td>
<td> </td>
</tr>
</table>

Can someone help to solve this problem
peterr


Posts: 5971
Posted: 03/26/2004, 8:30 AM

The content should not include <?php ... ?>.
Just "hello world" should be OK.
<table width="100%" border="1">
<tr>
<td>hello world
</td>
<td> </td>
</tr>
</table>

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
krmk
Posted: 03/26/2004, 9:18 AM

Ok. But what if I want to insert custom php code?
peterr


Posts: 5971
Posted: 03/26/2004, 9:30 AM

You should not need to insert the custom PHP code in the HTML. The custom code should do something, therefore you can insert the result of the PHP code, instead of the PHP code itself.
For example you can create a Label in your HTML, then assign the custom code to the Label.
http://docs.codecharge.com/studio/html/ProgrammingTechn...ntrolValue.html

For example:
$Output = "hello world";
$Label->SetValue($Output);
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
krmk
Posted: 03/26/2004, 9:41 AM

Ok. I uderstand but I'm trying to make something different. What I want to do is to include a PHP code snippet (that is not created with codecharge) in to apge created with Codecharge. Normaly you can do it with form element "include" but if you create the page with ccs, what I want is to include into a ccs created page a php code fro outside such as a calendar script.

By the way thanks for your prompt replies.
peterr


Posts: 5971
Posted: 03/26/2004, 9:55 AM

Yes, I've seen some requests like this before, but each time the answer is similar. You'd need to modify the other script to put the output into a variable, then assign that output to a Label.
There is no way to put PHP code into the HTML in CCS because the HTML is just a template. It's basically a file that is being read by the PHP program, then output to the browser. We use the ".html" extension because this template file contains HTML but in fact it could be a different filename like "PageName.tpl". It just doesn't work the same way as the standard HTML where you can mix some PHP.

The template approach has the benefit of separating the design from the programming code, but alternatively you could create this one page outside of CCS, using the standard PHP+HTML.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
krmk
Posted: 03/27/2004, 4:04 AM

My aim is not to mix PHP with HTML . What I try to to is to include a custom php code in a spesific location. So I try to use template variables to include the code and my custom php code does not have any html in it its only php code.

I can include any php code through beforeshow event but its always located at the very begining of the page not where I want. And this my problem.
peterr


Posts: 5971
Posted: 03/27/2004, 11:44 AM

The events are located at the beginning of the page, but they are being run/executed at different places within the program.
We have users who create very complex applications and execute custom PHP code everywhere throughout the program. I don't see any problem here.
You just need to decide what you want to do functionally, rather than "execute custom PHP". Every custom PHP code is different and is used for different purposes, and therefore may need to be placed in a different event.
You can see dozens of PHP code examples in our documentation. All of them are custom PHP code and work without problems. They only need to be placed in the correct event. You can also place the code in Common.php, or at the beginning of the PHP program or in the middle of PHP program. The possibilities are truly endless.
There are probably hundreds of possibile answers and solutions, depending on what you want to do. Almost every code is custom, so this to generic to discuss. As you can probably see, almost all answers in this forum are different, depending on what custom code users try to implement.
There is not a single answer. Otherwise this whole forum system would have only one topic :-)
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
krmk
Posted: 03/29/2004, 4:51 AM

Thanks for your help.
You are right there is no single naswer but I found mine. I have included my php file to a variable using output control functions. So I can now locate this variable wherever I want in the page.
feha


Posts: 712
Posted: 03/29/2004, 9:20 AM

You can convert your PHP code to the function then return it as variable
and use that variable ... to display the result.
_________________
Regards
feha

www.vision.to
feedpixel.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.