RE: Is it possible for part of a page to be a php i nclude ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Chris,
Again, this is no problem.  The included file is PHP code so you can
surround your conditional bits with PHP:

You can 'step' into and out of PHP using the '<? ... ?>' tags.  Whilst in
between the tags you are PHP and outside the tags you are HTML.  So your
page becomes a series of HTML/PHP/HTML/PHP/etc:


	<?
		// If we are on the home page then do something special.
		if ($currentPageName == HOME){
	?>
			<div>Welcome to the Home Page</div>
	
	<? else{ ?>
			<div>Welcome to some other page</div>
	<? } ?>

What actually happens is that all the code becomes PHP.  So you can think of
the above snippet as being equivalent to:


	<?
		// If we are on the home page then do something special.
		if ($currentPageName == HOME){
			print('<div>Welcome to the Home Page</div>');
		else{
			print('<div>Welcome to some other page</div>');
		}
	?>

The variable $currentPageName must have been defined before this point in
the code, either in this included file or available in the context in which
the file is included.  

Continue this thread if you have any further questions.

Brian

-----Original Message-----
From: Chris [mailto:Chris@xxxxxxxxxx] 
Sent: 04 April 2006 12:57
To: php-objects@xxxxxxxxxxxxxxx
Subject: RE:  Is it possible for part of a page to be a php
include ?

Hi Brian,

Many thanks for the input.

The page where the includes go *into* is no problem, but is there any way
that on the page where it's coming *from* that it can just get a part of
*that* page please?

I.e. on the page that the php include is coming *from*, there's stacks of
html including a few tables, but I would like just one of those tables to be
included on another page on another website.

Any help appreciated.

Chris. 

> -----Original Message-----
> From: php-objects@xxxxxxxxxxxxxxx
> [mailto:php-objects@xxxxxxxxxxxxxxx] On Behalf
Of Brian Etheridge
> Sent: Tuesday, April 04, 2006 1:25 PM
> To: 'php-objects@xxxxxxxxxxxxxxx'
> Subject: RE:  Is it possible for
part of a page 
> to be a php include ?
> 
> You just surround your included part with HTML,
or whatever.  
> As long as it
> makes syntactic sense there is no limitation:
> 
> 
> Here is my main.php page with many included
sections:
> 
> ============================================
> <html>
> <? include(LIBROOT . "header.inc"); ?> <body id='bodyElem' 
> onload='onLoadFunc();'
onunload='onUnLoadFunc();'>
> 
> <? include(LIBROOT . "top.inc"); ?>
> 
> <table class='tabledefn' width='100%' border='0'
cellpadding='3'
> cellspacing='0'>
> 	<tr>
> 		<td rowspan='2' align='center'
valign='top'>
> 			<!-- Left hand cell
occupies entire left hand
> column. -->
> 			<? include(LIBROOT .
"left.inc"); ?>
> 
> 	  	</td>
> 		<td valign='top' width="100%">
> 
> 			<!-- Centre cell contains
page contents. -->
> 			<?
> 				//print("<!--
Loading page "
> .$currentPage->getFileName() ." -->");
> 				include(LIBROOT
> .$currentPage->getFileName()
> .".inc");
> 			?>
> 
> 		</td>
> 		<td rowspan='2' valign='top'>
> 
> 			<!-- Right hand cell
occupies entire right hand
> column. -->
> 			<? include(LIBROOT .
"right.inc"); ?>
> 
> 	  	</td>
> 	</tr>
> </table>
> 
> </body>
> <? include(LIBROOT . "footer.inc"); ?> </html>
>
================================================= 
> 
> 
> Go for it.
> 
> Brian
> 
> -----Original Message-----
> From: Chris [mailto:Chris@xxxxxxxxxx]
> Sent: 04 April 2006 10:38
> To: php-objects@xxxxxxxxxxxxxxx
> Subject:  Is it possible for part
of a page to 
> be a php include
> ?
> 
> Does anyone know how to make *part* of a page to
be a php 
> include to go into
> another page please?
> 
> I know how to make a whole page to be the
included part, but 
> not a section
> of it.
> 
> Any help appreciated.
> 
> Chris
> 
> 



PHP Data object relational mapping generator http://www.metastorage.net/
Yahoo! Groups Links



 



PHP Data object relational mapping generator
http://www.metastorage.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux