CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> PHP

 object references in included pages

Print topic Send  topic

Author Message
blankenb

Posts: 125
Posted: 07/13/2004, 9:59 PM

Page in which "Content" is included: Content_Management_Center.php

include page name: Content
Form in Content page: Content1 (record form)
Control in Content1 Form: create_user_id_type


    global $Content;
    $Content->Content1->create_user_id_type->SetValue(CCGetSession("create_user_id_type"));

results in error: Fatal error: Call to a member function on a non-object in c:\wwwroot\en\customersupport\Content_events.php on line 220

Any hints on what is wrong with the syntax?
View profile  Send private message
johny_f

Posts: 23
Posted: 07/13/2004, 11:19 PM

Make sure, when you include page, that the name of the "include component" is the same as the name of the "include page".

I mean in the dialog box you have 2 lines to fill - one is name of include component and the second is the real name of the include page.

Otherwice you have to type all your codes with the name of the "include component" not the page:
global $Content_component; // (the real include page name is Content)
$Content_component->Content1->create_user_id_type->SetValue(CCGetSession("create_user_id_type"));


Hope this is clear,
I just spent few hours last week to solve such a problem.
_________________
Johny_f
View profile  Send private message
jwh

Posts: 13
Posted: 07/31/2004, 8:14 AM

Hi there,

At first, I'm new to CCS, PHP and to this forum, but I quickly figured out:

The people here and at YES, as well as CCS are all GREAT !!!

I have run into trouble with the same Error Message but for a different reason (and after reading and trying for hours I decided to ask here, sorry for the long post, maybe it's also long because of my "German" nature ;-))

My Goal: implement "template-like" Pages with some functionality includable
almost everywhere for example in other included pages and also multiple times within the same page.

So when I include a given "special function include" page twice on the same "main" page, it gets a different name (and its own instance of the include pages class) which is fine.

So I can access the objects of these included instances from the main page by theire different names, works fine.

But because of the different names of these instances I figured out a way to get the include pages current instance "path" by calling the function debug_backtrace() and building the "path" to the wanted instance by searching for the entry with the requested classname. The whole thing is implemented in the "BeforeShow -Event of the Include Page.

As long as the Include Page is included within the main page, averything works ok, but if it is included by another level of included page, I can't figure out how to address it correctly.

So my Test Scenario:

The Main Page "m" which has one HTML-String, one inclusion of the "special include page" "i" with the "instance"-name "i", one inclusion of the same page "i" but this time with the special name "i1"
and one inclusion of another include page "s".

The Page "s" has nothing but an inclusion of the "special page" "i".

The "Special Page "i" has just a HTML String and a TextBox-Object "TextBox1"

If I don't code any Event-Code the visual Result is a Page with

first the String from the main page, followed 3 times by the string and an empty TextBox from the page "i" (two times from the inclusion within the main page, and one time from the inclusion via the intermediate page "s".

In the "BeforeShow" -Event of the main page I can access the TextBox1 by their names "$i-TextBox1-SetValue("Hello")", "$i1->TextBox1-SetValue("Hello1")" and "$s->i->TextBox1-SetValue("Hello2")".

Within the "BeforeShow"-Event of the "i"-Page itself, I can access these Pages with their "hardcoded" names as well, but normaly I don't know these names.

So here is my Event-code (the problem part is marked by !!!!!!!!:

-------------------------------------------------------------------------------------------

echo "<pre>";
$stack = debug_backtrace();
//print_r($stack);
$highest = array_pop($stack);
//echo "highest: ";
//print_r($highest);
$caller = $highest["args"][0];
global $$caller;
while ($highest['class'] != 'clsi') {
if ($callchain) {
$callchain = $callchain . '->';
}
if ($caller) {
$caller = $caller . '->';
}
$highest = array_pop($stack);
//echo "highest: ";
//print_r($highest);
$callchain = $callchain . $highest["args"][0];
$caller = $caller . $highest["args"][0];
}

printf("My Caller originally came from object instance: %s<br>", $caller);
printf("My Callchain is: %s<br>", $callchain);
if ($callchain) {
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//this one does NOT work
$$caller->$callchain->TextBox1->SetValue('Hello my friends');
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
} else {
// this on works
$$caller->TextBox1->SetValue('How is life?');
}
// the hard coded way works fine
//$i->TextBox1->SetValue('Hello');
//$i1->TextBox1->SetValue('Hello');
//$s->i->TextBox1->SetValue('Hello');

echo "</pre>";

---------------------------------------------------------------------------------------------

Any help is very welcome, If you think that's the wrong place to ask
this whole long question so please advise me to the right place,
If something (or even the whole thing) is unclear, please let me know.

thanks in advande and enjoy your day

cu jwh


Jan W. Hentsch (jwh@csmed.de)
CSMed GmbH, Darmstadt
Germany
View profile  Send private message
jwh

Posts: 13
Posted: 07/31/2004, 8:25 AM

Sorry, made a mistake by copying the code fragment into the Mesage,
I intermixed two different versions, so here is the correct code:

-------------------------------------------------------------------------------------------

echo "<pre>";
$stack = debug_backtrace();
//print_r($stack);
$highest = array_pop($stack);
//echo "highest: ";
//print_r($highest);
$caller = $highest["args"][0];
global $$caller;
while ($highest['class'] != 'clsi') {
if ($callchain) {
$callchain = $callchain . '->';
}
$highest = array_pop($stack);
//echo "highest: ";
//print_r($highest);
$callchain = $callchain . $highest["args"][0];
}

printf("My Caller originally came from object instance: %s<br>", $caller);
printf("My Callchain is: %s<br>", $callchain);
if ($callchain) {
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//this one does NOT work
$$caller->$callchain->TextBox1->SetValue('Hello my friends');
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
} else {
// this on works
$$caller->TextBox1->SetValue('How is life?');
}

// the hard coded way works fine
//$i->TextBox1->SetValue('Hello');
//$i1->TextBox1->SetValue('Hello');
//$s->i->TextBox1->SetValue('Hello');

echo "</pre>";

---------------------------------------------------------------------------------------------

thanks again,

cu jwh
View profile  Send private message
Damian
Posted: 08/03/2004, 6:20 AM

Hiya JWH,

I have tried including an include with an include -unsuccessfully-
We just stopped trying :( and had to make a few extra include pages that did
all the required functions. Its still pretty efficient, although not quite
as efficient as it could be...

Damian


"jwh" <jwh@forum.codecharge> wrote in message
news:5410bb9f4338e3@news.codecharge.com...
> Sorry, made a mistake by copying the code fragment into the Mesage,
> I intermixed two different versions, so here is the correct code:
>
> --------------------------------------------------------------------------
-----------------
>
> echo "<pre>";
> $stack = debug_backtrace();
> //print_r($stack);
> $highest = array_pop($stack);
> //echo "highest: ";
> //print_r($highest);
> $caller = $highest["args"][0];
> global $$caller;
> while ($highest['class'] != 'clsi') {
> if ($callchain) {
> $callchain = $callchain . '->';
> }
> $highest = array_pop($stack);
> //echo "highest: ";
> //print_r($highest);
> $callchain = $callchain . $highest["args"][0];
> }
>
> printf("My Caller originally came from object instance: %s<br>", $caller);
> printf("My Callchain is: %s<br>", $callchain);
> if ($callchain) {
>
>
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> //this one does NOT work
> $$caller->$callchain->TextBox1->SetValue('Hello my friends');
>
>
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
> } else {
> // this on works
> $$caller->TextBox1->SetValue('How is life?');
> }
>
> // the hard coded way works fine
> //$i->TextBox1->SetValue('Hello');
> //$i1->TextBox1->SetValue('Hello');
> //$s->i->TextBox1->SetValue('Hello');
>
> echo "</pre>";
>
> --------------------------------------------------------------------------
-------------------
>
>
> thanks again,
>
> cu jwh
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

jwh

Posts: 13
Posted: 08/04/2004, 2:06 AM

Hi Damian,

what do You exactly mean by "unsuccessfully"? I think the only problem is
how to address the objects of the include page from insight insight the include
itself "see the hardcoded way from my example, this works"

My only problem is, I can`t figure out how to specify those addresses dynamically
and not hardcoded.

Maybe someone else can help us?!?!?!?

cu jwh
View profile  Send private message
Philip
Posted: 10/30/2004, 6:45 PM

Th
Thank you johny_F!
You helped me solve this same peoblem I had spent hours on!
:-)

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.