CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Placing custom code script [SOLVED]

Print topic Send  topic

Author Message
ksa

Posts: 27
Posted: 06/08/2008, 7:24 AM

I may be pretty dense when it comes to php, but I've been trying to solve this problem for hours, but can't seem to do it.

The thing is, I have found a free php script that allows you to include a poll on your page. The main part of the script is in a file called poll.php. Now I want to call that script and make the poll appear at the desired position on the page. The installation guide for the script tells you to use the line include("poll.php"); in order to call it. So in CCS4's design view I create a CodeExpression label where I want to display the poll and add that piece of code as a "Before Show" custom code snippet. The result is that I get a page with only the poll and nothing else. The rest of my page is not there. I have also managed to make the poll appear at the very top of the page, very far from where I actually put the label.

It's possible I do it all completely wrong, but after hours of searching this forum and reading CCS documentation I haven't figured it out, so I hope someone can help.
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/08/2008, 7:34 AM

Try, set label property to HTML and not TEXT.

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
ksa

Posts: 27
Posted: 06/08/2008, 9:25 AM

That's one of the things I did try, and no, it didn't make any difference, I'm afraid.
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/08/2008, 11:52 AM

Hi

Not having seen the code, it is hard to tell.

You ar not putting the include in the before show event are you?

What you need to do it find somne white space in your events script (Usually right at top befor the bind events) and place your include there. Be sure the poll code does no output.

Then make your calls where ever you want. before show, before initialize. I am assuming the poll call returns some value. I don't know cant' see it.

Anyway what ever calls you make and what ever data is returned then you can place it into a CCS control or somting for display.

Let me know if that helps as I am not sure exactly what your code is doing. This is just a guess

Have fun

_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/08/2008, 12:13 PM

well said, John.
Fast other option is blank page and port the code in.
Then turn that page into an include page.
That can be included anywhere on any other page (portal style, right column cliplet)

But, indeed we need to see some code.

[to port = translate the code to CCS style code as it will most cetrainly have DB interaction as well)

Walt,
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
mentecky

Posts: 321
Posted: 06/08/2008, 1:36 PM

This one isn't for the meek, but I think I know what you are looking for.

First create a label where you want the poll code. Set it's "Content" property to HTML like Walter suggested. Then in events add custom code to Before Show. Now, I'm just guessing because like John said we haven't seen your code, but try something like this:

   ob_start();  
   include ("poll.php");  
   $html =ob_get_contents();  
   ob_end_clean();  
  
   $poll_label->SetValue($html);  

What the above does is captures any output into a variable, $html, then you set your label value to that captured output.

Hope that helps.

Rick

_________________
http://www.ccselite.com
View profile  Send private message
ksa

Posts: 27
Posted: 06/08/2008, 3:32 PM

Thanks for all your replies. Haven't had time to try yet, but will do so ASAP and let you know.
View profile  Send private message
ksa

Posts: 27
Posted: 06/10/2008, 12:57 PM

Thanks once again for your replies. I started out trying the last solution because that looked the simplest, and lo and behold, it did the trick.

So, problem solved! Thank you!
View profile  Send private message
wkempees


Posts: 1679
Posted: 06/10/2008, 1:59 PM

@ksa
Congrats.
Please change topic title to [SOLVED] or [TIP], by edit of your first post.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
jjrjr1


Posts: 942
Posted: 06/10/2008, 10:37 PM

Rick,,

That is very elegant.

I want to remember that method.

To Cool

Thanks
_________________
John Real - More CodeCharge Studio Support at - http://CCSElite.com
View profile  Send private message
mentecky

Posts: 321
Posted: 06/11/2008, 1:53 AM

Quote ksa:
Thanks once again for your replies. I started out trying the last solution because that looked the simplest, and lo and behold, it did the trick.

So, problem solved! Thank you!

No problem ksa! I battled with that one a while ago.

John, Thanks!

Rick
_________________
http://www.ccselite.com
View profile  Send private message
mentecky

Posts: 321
Posted: 06/11/2008, 1:59 AM

ksa,

You may want to post your poll solution for others now that you have it working.

Just a thought,

Rick
_________________
http://www.ccselite.com
View profile  Send private message
maxhugen

Posts: 272
Posted: 08/27/2008, 9:58 PM

I've tried this, but something isn't right, and I'm struggling...

I have a Privacy page at www.gardenloco.com/Privacy.php . I need to display this as a Popup Window from a few places in the site, so I designed a page 'Popup.php' that has less 'chrome' (ie, no menus etc). I took the content from Privacy.php, and made it an include, Privacy_inc.php, so that it is included in Privacy.php.

I'm trying to call www.gardenloco.com/Popup.php?inc=Privacy_inc.php and have the generic 'Popup.php' insert the inc dynamically.

Following Rick's example above, I added a Label called 'DynamicIncludePage', set its to Content=HTML, and added code in the Page_BeforeShow event:
    // get the include page to insert  
    $inc = CCGetParam("inc", "");  
  
    // get the contents of the include page  
    ob_start();    
    include($inc);    
    $html = ob_get_contents();    
    ob_end_clean();   
       
echo "here's the html: ".$html;  
  
    // insert the content into the Label  
    $Component->DynamicIncludePage->SetValue($html);    

I've checked (using echo) that I get the URL param OK, but when I echo $html, I'm not getting anything. Can anyone suggest where I've cocked it up?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/28/2008, 3:31 AM

Max,

Change
  
ob_start();      
    include($inc);      
    $html = ob_get_contents();      
    ob_end_clean();      
into
  
//  ob_start();      
print 'value of include' .    include($inc);      
//    $html = ob_get_contents();      
//    ob_end_clean();         
This should echo the value of your include parameter $inc.
You can then look at that and see if:
a/ $inc is filled
b/ pathname is ok

Walter



_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/28/2008, 4:08 AM

Tested this, works:
  
	$inc = CCGetParam("inc_file","");  // get and set the parm, variable  
//	echo 'include file : '. $inc;                // debug, remove //   
	ob_start();    
   	if (include ($inc) )                             // include only if file exists  
	    $html =ob_get_contents();        // stream only if anything to stream  
     ob_end_clean();                                 //close stream  
     $Component->SetValue($html);    // assign result to component (must be label! content HTML  

Next steps if still not working:
Did you publish [F9] your project, is the include at target server?
Any path problems?

This code snippet is meant purely to help you on your syntax.
Please be advised that I do not subscribe/endorse the method you are using.
I consider it dangerous, to have a 'injection'method and show your visitors how to inject code.
You should at least check if the passed include file is your own and/or from within your own domain!
It would be easier just to create privacy_popup.php and plainly include your privacy stuff, or make it a dedicated text popup.
Dynamic includes ok, but this method not.

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
maxhugen

Posts: 272
Posted: 08/28/2008, 5:20 PM

Hi Walter

I hadn't thought of the 'injection' issue you raised... I will indeed have to add code to check the inc is my own file ! However, I'd still like to find the prob I've got with my code, as I can see this technique being potentially useful for dynamically including content in other situations.

    print 'value of include: ' .    include($inc);    
prints:  
    value of include: 1
So its finding the file to include OK.

I tried moving the code from the Page_BeforeShow to DynamicIncludePage_BeforeShow, but it's still not working. I've double-checked that the Label 'DynamicIncludePage' is set to Content=HTML.

    $inc = CCGetParam("inc", "");  
//print 'value of include: ' .    include($inc);        
  
    ob_start();    
    if (include($inc))  
        $html = ob_get_contents();    
    ob_end_clean();   
  
//echo "here's the html: ".$html;  
    $Component->SetValue($html);  

Is there a way to 'dump' the contents of the inc to screen perhaps?
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/28/2008, 5:39 PM

DynamicIncludePage label BeforeShow
set to Content=HTML.

Create a simple include file first.
name it my_inc.php
  
<?php  
echo "thank you, walter";  
?  
now save that in your project dir, and publish all, or manualy copy it to target root.
put it in your URL?inc=my_inc.php
and see it display nicely.

My bet is, your include does not have the php directives <?php ..... ?>

Walter
_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
maxhugen

Posts: 272
Posted: 08/28/2008, 5:49 PM

Hmmm... that does indeed work!

Does that mean that I can't use a normal CCS Include Page then? :-<
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/28/2008, 6:08 PM

How to find the answer to that question.......

Make an includable page.
On a Form, that is what we are talking about (Grid eGrid)
position cursor anywhere and choose from Form Tools Include Page.
Watch closely the text of the error message.... lol
Can only be on a page.
You face redeclaration of almost anything.
No cannot be done, at least not like this.. (don't ask please, holiday planned)

Walter

_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
View profile  Send private message
maxhugen

Posts: 272
Posted: 08/28/2008, 6:21 PM

Oh bugger! I thought adding/changing CCS Include Pages via code 'on the fly' would be really cool... back to the drawing board.

Thanks anyway Walter, and enjoy your hols.

Cheers, Max
_________________
Max
www.gardenloco.com | www.eipdna.com | www.chrisarminson.com
View profile  Send private message
wkempees


Posts: 1679
Posted: 08/28/2008, 6:24 PM

I will, thanks.
Suggest open new topic, 'Dynamic Includes of Includable pages, Anyone?'
Might trigger some interest.

Walter


_________________
Origin: NL, T:GMT+1 (Forumtime +9)
CCS3/4.01.006 PhP, MySQL .Net/InMotion(Vista/XP, XAMPP)

if you liked this info PAYPAL me: http://donate.consultair.eu
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.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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