Gaaaz
|
| Posted: 04/21/2003, 5:35 AM |
|
Hello,
I am trying to include some pieces of code on a CCS2 page. The thing is that some of them are ready-made and working nice so I don't want to write them again with CCS2...
Include doesn 't help, the external code is placed on top of all CCS2 elements when page is executed.
I guess that when the template is parsed, CCS2 must stop at my tag, execute it, get the results and add them at the template variable before continue parsing the rest of the CCS2 page... But how can it be done?
Does anyone have a clue?
Thanks,
Gaaaz
|
|
|
 |
RonB
|
| Posted: 04/21/2003, 7:36 AM |
|
Just a guess, in a beforeshow event? Copy and paste the code.
Ron
|
|
|
 |
Dirk
|
| Posted: 04/21/2003, 12:09 PM |
|
Hi Gaaaz and Ron,
you have almost the same question like mine. See 4/20/2003 DirkD "Where to put the JAvaSctipt in CC2". But as I understand you use CCS. Maybe the solution will be the same as for CC2. Please read my question and when you know the solution I like to be informed ! (dirk@induxion.nl)
|
|
|
 |
Zye
|
| Posted: 04/23/2003, 5:29 AM |
|
Bump .... CCS Latest - PHP 4 with Templates, MySQL
I have the same concern. I am trying to include a text file or SHTML page to show some stats but my includes (PHP virtual command or any PHP code I have tried) just places the result above the header.
Please Help us if it is possible :) There are a few posts on this forum with no answers that work.
Thanks ...
|
|
|
 |
Chillout
|
| Posted: 04/24/2003, 5:13 AM |
|
Bump ...
|
|
|
 |
murri
|
| Posted: 04/26/2003, 9:24 AM |
|
hi Gaaaz,
wich language?
you can change the function LoadTemplate() in file template.(language)...
change this function to your needs:
- grap code from html template file into a variable
- execute code with some functions like in php: eval($var)
hope it helps...
murri
|
|
|
 |
RonB
|
| Posted: 04/27/2003, 9:26 AM |
|
copy the complete code of the includable file. On the position you want the outcome to show add, in html, a tag => {my_include}. You could insert a tabel and set the tag inside the <td></td> => <td>{myinclude}</td>.
create an event with the set tag as action. Go to the event code
Now create a variable, let's say $my_var. now atach the code of your include as the value of $my_var="a whole bunch of code...";
now alter the set tag code to hold $my_var.
If everything works as it should this should work and output the outcome to the desired position.
I think.... 
Ron
|
|
|
 |
Gaaaz
|
| Posted: 04/27/2003, 11:19 AM |
|
Alex (Yes team) had an excellent suggestion:
global $Tpl;
$Tpl->Setvar("Variable_name",join "",file "http://localhost/file_to_include.php")));
If you put this at Page->before show event it will execute file_to_include.php and put the results at the variable {Variable_name}. It helped me a lot, I hope you find it useful.
|
|
|
 |
Kevin A
|
| Posted: 04/27/2003, 2:32 PM |
|
-- If you show an example please make sure it WORKS! )))
Html Code:
<html>
<head>
<title>Black</title>
</head>
<body>
{insertpoint}
</body>
</html>
Event Code:
//Page_BeforeShow @1-D8BD2467
function Page_BeforeShow()
{
$Page_BeforeShow = true;
//End Page_BeforeShow
//Custom Code @11-2A29BDB7
// -------------------------
global $Tpl;
$Tpl->Setvar(insertpoint,implode(file("http://aca5/cart/clue.php")));
// -----note: join is an alias for implode: make array a string
// ----- file: read file and make array ---------------
//End Custom Code
//Close Page_BeforeShow @1-4BC230CD
return $Page_BeforeShow;
}
//End Close Page_BeforeShow
The examples given in the online help are usless.......
|
|
|
 |
Zye
|
| Posted: 04/30/2003, 5:55 PM |
|
Still not working for me where am I going wrong. (PHP)
In Page Beforshow
global $Tpl;
$Tpl->Setvar(useronline,implode(file("useronline.php")));
Result
Warning: Wrong parameter count for implode() in /home/leadmill/public_html/db/home_events.php on line 111
What parameter needs to counted?
Thanks
|
|
|
 |
RonB
|
| Posted: 05/01/2003, 12:43 PM |
|
implode needs two parameters to work, the file, array etc and the seperation character for example:
$data = implode("",file($filename));
Straight from the php manual 
Ron
|
|
|
 |