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

 Dynamic Includes

Print topic Send  topic

Author Message
ajazza
Posted: 09/13/2005, 5:39 PM

I have done quite a thorough search on this but haven't found a solution that will work.

What I have is a generic page... "home.php" that is called with a variable.. such as home.php?page=1 or home.php?page=2 etc etc

All content to be displayed is pulled from the database, by way of various include files.

I have one include file "display_page_content" that populates the main content of that particular page.

All of this is working perfectly so far :-)

Now My Problem
Some pages require the inclusion of generic forms, for example "home.php?page=2" requires a contact form to be displayed.

All of my forms are stored in includes/forms/

how can I get this to work?
I have tried reading the page and displaying the appropriate form as necessary, but this isn't working for me.

Any help, much appreciated.
Adam
DonB
Posted: 09/13/2005, 9:12 PM

I usually put a PHP switch() statement in the Main page's BeforeShow event,
and based on CCGetParam("page","") would set Visible=true for the
appropriate Include while setting Visible=false for all the others.

Is that what you are doing?

--
DonB

http://www.gotodon.com/ccbth


"ajazza" <ajazza@forum.codecharge> wrote in message
news:543277145edeaa@news.codecharge.com...
> I have done quite a thorough search on this but haven't found a solution
that
> will work.
>
> What I have is a generic page... "home.php" that is called with a
variable..
> such as home.php?page=1 or home.php?page=2 etc etc
>
> All content to be displayed is pulled from the database, by way of various
> include files.
>
> I have one include file "display_page_content" that populates the main
content
> of that particular page.
>
> All of this is working perfectly so far :-)
>
> Now My Problem
> Some pages require the inclusion of generic forms, for example
> "home.php?page=2" requires a contact form to be displayed.
>
> All of my forms are stored in includes/forms/
>
> how can I get this to work?
> I have tried reading the page and displaying the appropriate form as
necessary,
> but this isn't working for me.
>
> Any help, much appreciated.
> Adam
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Ajazza
Posted: 09/13/2005, 9:31 PM

Thanks, that sounds like the trick I need.

could you give an example of how you reference the included page to set it to visible.

Cheers
Adam
DonB
Posted: 09/14/2005, 6:33 AM

$includecontrol->Visible = false;

I find it's best to keep the Include control's name the same as the Include
page itself. There's something wrong with the name resolution, or my
understanding of how it's supposed to work, if they are different. If not
the same, you'll get an error about "calling a member function of a
non-object".

So, if the Include page you create is named "IncludePage" and the Include
control inserted in your main page is also "IncludePage", then add this to
your main page:

global $IncludePage;
$IncludePage->Visible = false;

--
DonB

http://www.gotodon.com/ccbth


"Ajazza" <Ajazza@forum.codecharge> wrote in message
news:54327a7907b2b8@news.codecharge.com...
> Thanks, that sounds like the trick I need.
>
> could you give an example of how you reference the included page to set it
to
> visible.
>
> Cheers
> Adam
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Ajazza
Posted: 09/14/2005, 2:37 PM

Hi DonB.
I appreciate your help... however I don't have it sorted yet...
Here is what i have and what i have done.

Scenario
I have a main page (home.php) that includes various other pages (menu, title etc)
The include of importance is "display_content.php"
"display_content.php" queries the database based on what page is being requested (home.php?page=3) for example. And it should also include the appropriate forms.

Testing
So to test your code... in the Before Show Event of display_content I have the following....
  
global $newsletter;  
	$page = CCGetParam("page","");  
	switch ($page) {  
		case 1:  
			 $newsletter->Visible = false;  
			 break;  
	}  
and I have included the page "newsletter.php" which is a form located at includes/forms/newsletter.php

Outcome
so, I would suspect when I browse to home.php?page=1 the form would not show, however this doesn't work, it still shows.
So, I tried to set $newsletter->Visible = false; by itself, and that does not work either.

I guess I am missing something simple here, but not sure what.

Regards
Adam
DonB
Posted: 09/14/2005, 4:22 PM

Not right. You must show/hide the includes from the MAIN page (home.php)
BeforeShow event. Trying to hide an Include from the Include's BeforeShow
is too late - it's already in the midst of being "shown" by the time that
event occurs.

--
DonB

http://www.gotodon.com/ccbth


"Ajazza" <Ajazza@forum.codecharge> wrote in message
news:54328981d7d66c@news.codecharge.com...
> Hi DonB.
> I appreciate your help... however I don't have it sorted yet...
> Here is what i have and what i have done.
>
> Scenario
> I have a main page (home.php) that includes various other pages (menu,
title
> etc)
> The include of importance is "display_content.php"
> "display_content.php" queries the database based on what page is being
> requested (home.php?page=3) for example. And it should also include the
> appropriate forms.
>
> Testing
> So to test your code... in the Before Show Event of display_content I have
the
> following....
>
  
> global $newsletter;  
> $page = CCGetParam("page","");  
> switch ($page) {  
> case 1:  
> $newsletter->Visible = false;  
> break;  
> }  
> 
> and I have included the page "newsletter.php" which is a form located at
> includes/forms/newsletter.php
>
> Outcome
> so, I would suspect when I browse to home.php?page=1 the form would not
show,
> however this doesn't work, it still shows.
> So, I tried to set $newsletter->Visible = false; by itself, and that does
not
> work either.
>
> I guess I am missing something simple here, but not sure what.
>
> Regards
> Adam
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

Ajazza
Posted: 09/14/2005, 4:43 PM

For testing I have put the following code into the main page...

  
global $newsletter;  
$newsletter->Visible = false;  


.and that does not work either
the code for my included form on display_content is...
{newsletter}

Do i need to wrap the include with something like...
  
<!-- BEGIN Form newsletter -->  
{newsletter}  
<!-- END Form newsletter -->  

Thanks again
Adam
DonB
Posted: 09/14/2005, 7:19 PM

Nope, the BEGIN/END is not required. I can't figure out what is wrong on
your end, because it works - I do it ALL the time.

I think you should enlist the support.codecharge.com folks and have them
take a look at it. Something's misbehaving.

--
DonB

http://www.gotodon.com/ccbth


"Ajazza" <Ajazza@forum.codecharge> wrote in message
news:54328b5ac78882@news.codecharge.com...
> For testing I have put the following code into the main page...
>
>
  
> global $newsletter;  
> $newsletter->Visible = false;  
> 
>
> and that does not work either
> the code for my included form on display_content is...
>
{newsletter}
>
> Do i need to wrap the include with something like...
>
  
> <!-- BEGIN Form newsletter -->  
> {newsletter}  
> <!-- END Form newsletter -->  
> 
>
> Thanks again
> Adam
> > --------------------------------------- > Sent from YesSoftware forum > http://forums.codecharge.com/ >
Walter Kempees
Posted: 09/15/2005, 8:00 PM

DonB

I know..................> False mind the uppercase F i've been 'for F er'
doing this.
  
global $newsletter;  
$newsletter->Visible = False;  

Walter


"DonB" <~ccbth~@gotodon.com> schreef in bericht
news:dgalng$u4a$1@news.codecharge.com...
> Nope, the BEGIN/END is not required. I can't figure out what is wrong on
> your end, because it works - I do it ALL the time.
>
> I think you should enlist the support.codecharge.com folks and have them
> take a look at it. Something's misbehaving.
>
> --
> DonB
>
> http://www.gotodon.com/ccbth
>
>
> "Ajazza" <Ajazza@forum.codecharge> wrote in message
>news:54328b5ac78882@news.codecharge.com...
>> For testing I have put the following code into the main page...
>>
>>
  
>> global $newsletter;  
>> $newsletter->Visible = false;  
>> 
>>
>> and that does not work either
>> the code for my included form on display_content is...
>>
{newsletter}
>>
>> Do i need to wrap the include with something like...
>>
  
>> <!-- BEGIN Form newsletter -->  
>> {newsletter}  
>> <!-- END Form newsletter -->  
>> 
>>
>> Thanks again
>> Adam
>> >> --------------------------------------- >> Sent from YesSoftware forum >> http://forums.codecharge.com/ >> > >
Ajazza
Posted: 09/15/2005, 8:17 PM

:-) :-) :-)

Thanks for the help everyone, the answer was simple... I had to reference the included page like so... because it was included in another include

  
global $display_page_content;  
$display_page_content->newsletter->Visible = false;  

Display_page_content includes another page 'newsletter'
Once again, thanks for your help.
Regards
Adam.

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.