Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Website » Better template.php ?
Better template.php ? [message #18057] Tue, 14 November 2006 03:52 Go to next message
Michal Chmielewski is currently offline Michal ChmielewskiFriend
Messages: 58
Registered: July 2009
Member
So ... the basic template for generating pages in projects using this
php Phoenix magic looks like this:

--- snip -----
<?php ## The "require" magic is "off-screen"

# Begin: page-specific settings. Change these.
$pageTitle = "Sample Phoenix web page using the new templates";
$pageKeywords = "Type, page, keywords, here";
$pageAuthor = "Type your name here";

# Add page-specific Nav bars here
# $Nav->addCustomNav("My Link", "mypage.php", "_self", 3);
# $Nav->addCustomNav("Google", "http://www.google.com/", "_blank", 3);

# Paste your HTML content between the EOHTML markers!
$html = <<<EOHTML

html goes here.

EOHTML;

# Generate the web page
$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords,
$pageTitle, $html);
?>
--- snip -----


I am not very familiar with PHP but the $html = <<< EOHTML line is
really making the HTML content be buried in the PHP code. This is bad
for 2 reasons:

1) I can't use simple PHP include(file) directive to include content
that I may need in more then 1 place.
2) The PHPEclipse editor syntax highlighting is completely shot for the
HTML that is buried in the PHP code.

I read a little about output buffering in PHP and this template seems
more logical to me and fixes these 2 issues.

Changes have the <-- comment next to them

--- snip -----
<?php ## The require magic is "off-screen"
ob_start(); # <-- turns on buffering
# Begin: page-specific settings. Change these.
$pageTitle = "Sample Phoenix web page using the new templates";
$pageKeywords = "Type, page, keywords, here";
$pageAuthor = "Type your name here";

# Add page-specific Nav bars here
# $Nav->addCustomNav("My Link", "mypage.php", "_self", 3);
# $Nav->addCustomNav("Google", "http://www.google.com/", "_blank", 3);
# <-- now close the PHP code section
?>

HTML goes here. PHPEclipse will nicely hilite the syntax because now it
knows that it is in the "html" area and give me HTML templates as I need
them via code assist.

You can do also things like <?= $pageAuthor ?> which are PHP escapes for
expressions.

You can also include pages such as ...
<?php include("some.page.html") ?>

<?php
# Generate the web page.
# <-- ob_get_clean() will get the currently produced output which
# <-- sits in the buffer and erase the buffer so that
# <-- App->generatePage() can do the chrome around the page content
#
$App->generatePage($theme, $Menu, $Nav, $pageAuthor, $pageKeywords,
$pageTitle, ob_get_clean() );
?>
--- snip -----

This is working locally, on local.eclipe.org installation, and I presume
that it should work on Eclipse.org once checked in. However, there may
be some php configuration parameters that may not be set in the same way.

Anything that I am missing ?

-michal
Re: Better template.php ? [message #18069 is a reply to message #18057] Tue, 14 November 2006 15:56 Go to previous messageGo to next message
Bjorn Freeman-Benson is currently offline Bjorn Freeman-BensonFriend
Messages: 334
Registered: July 2009
Senior Member
That is the way I write pages for the eclipse.org website. See for
example: /projects/europa.php
The only additional thing I use is:

$html = ob_get_contents();
ob_end_clean();
$App->generatePage( ..., $html, ... );

The ob_end_clean allows further code to write to the output stream
normally. See http://us3.php.net/ob_get_contents

Michal Chmielewski wrote:
> I am not very familiar with PHP but the $html = <<< EOHTML line is
> really making the HTML content be buried in the PHP code.
> ...
> I read a little about output buffering in PHP and this template seems
> more logical to me and fixes these 2 issues.
> Anything that I am missing ?
Re: Better template.php ? [message #18081 is a reply to message #18069] Tue, 14 November 2006 17:19 Go to previous messageGo to next message
Eclipse Webmaster is currently offline Eclipse WebmasterFriend
Messages: 607343
Registered: July 2009
Senior Member
Indeed, Bjorn's use of the output buffer makes a much cleaner (and
better) implementation. Most of our pages use it, but I have yet to
update the templates.

D.



Bjorn Freeman-Benson wrote:
> That is the way I write pages for the eclipse.org website. See for
> example: /projects/europa.php
> The only additional thing I use is:
>
> $html = ob_get_contents();
> ob_end_clean();
> $App->generatePage( ..., $html, ... );
>
> The ob_end_clean allows further code to write to the output stream
> normally. See http://us3.php.net/ob_get_contents
>
> Michal Chmielewski wrote:
>> I am not very familiar with PHP but the $html = <<< EOHTML line is
>> really making the HTML content be buried in the PHP code.
> > ...
>> I read a little about output buffering in PHP and this template seems
>> more logical to me and fixes these 2 issues.
>> Anything that I am missing ?
Re: Better template.php ? [message #18622 is a reply to message #18081] Tue, 14 November 2006 17:24 Go to previous messageGo to next message
Eclipse Webmaster is currently offline Eclipse WebmasterFriend
Messages: 607343
Registered: July 2009
Senior Member
Actually, most of the newer pages I create are set up for
multi-language/localized content:

template.php:
-- snip --
# Place your html content in a file called content/en_template.php
include($App->getLocalizedContentFilename());

# Generate the web page
$App->generatePage(...)

--snip--

Where all my HTML content lies in
content/[en|fr|de|etc...]_template.php, allowing for localized content.

D.



Denis Roy wrote:
> Indeed, Bjorn's use of the output buffer makes a much cleaner (and
> better) implementation. Most of our pages use it, but I have yet to
> update the templates.
>
> D.
>
>
>
> Bjorn Freeman-Benson wrote:
>> That is the way I write pages for the eclipse.org website. See for
>> example: /projects/europa.php
>> The only additional thing I use is:
>>
>> $html = ob_get_contents();
>> ob_end_clean();
>> $App->generatePage( ..., $html, ... );
>>
>> The ob_end_clean allows further code to write to the output stream
>> normally. See http://us3.php.net/ob_get_contents
>>
>> Michal Chmielewski wrote:
>>> I am not very familiar with PHP but the $html = <<< EOHTML line is
>>> really making the HTML content be buried in the PHP code.
>> > ...
>>> I read a little about output buffering in PHP and this template seems
>>> more logical to me and fixes these 2 issues.
>>> Anything that I am missing ?
Re: Better template.php ? [message #18644 is a reply to message #18069] Tue, 14 November 2006 18:29 Go to previous message
Michal Chmielewski is currently offline Michal ChmielewskiFriend
Messages: 58
Registered: July 2009
Member
Sounds good.
-m
Bjorn Freeman-Benson wrote:
> That is the way I write pages for the eclipse.org website. See for
> example: /projects/europa.php
> The only additional thing I use is:
>
> $html = ob_get_contents();
> ob_end_clean();
> $App->generatePage( ..., $html, ... );
>
> The ob_end_clean allows further code to write to the output stream
> normally. See http://us3.php.net/ob_get_contents
>
> Michal Chmielewski wrote:
>> I am not very familiar with PHP but the $html = <<< EOHTML line is
>> really making the HTML content be buried in the PHP code.
> > ...
>> I read a little about output buffering in PHP and this template seems
>> more logical to me and fixes these 2 issues.
>> Anything that I am missing ?
Re: Better template.php ? [message #570105 is a reply to message #18057] Tue, 14 November 2006 15:56 Go to previous message
Bjorn Freeman-Benson is currently offline Bjorn Freeman-BensonFriend
Messages: 334
Registered: July 2009
Senior Member
That is the way I write pages for the eclipse.org website. See for
example: /projects/europa.php
The only additional thing I use is:

$html = ob_get_contents();
ob_end_clean();
$App->generatePage( ..., $html, ... );

The ob_end_clean allows further code to write to the output stream
normally. See http://us3.php.net/ob_get_contents

Michal Chmielewski wrote:
> I am not very familiar with PHP but the $html = <<< EOHTML line is
> really making the HTML content be buried in the PHP code.
> ...
> I read a little about output buffering in PHP and this template seems
> more logical to me and fixes these 2 issues.
> Anything that I am missing ?
Re: Better template.php ? [message #570119 is a reply to message #18069] Tue, 14 November 2006 17:19 Go to previous message
Eclipse Webmaster is currently offline Eclipse WebmasterFriend
Messages: 607343
Registered: July 2009
Senior Member
Indeed, Bjorn's use of the output buffer makes a much cleaner (and
better) implementation. Most of our pages use it, but I have yet to
update the templates.

D.



Bjorn Freeman-Benson wrote:
> That is the way I write pages for the eclipse.org website. See for
> example: /projects/europa.php
> The only additional thing I use is:
>
> $html = ob_get_contents();
> ob_end_clean();
> $App->generatePage( ..., $html, ... );
>
> The ob_end_clean allows further code to write to the output stream
> normally. See http://us3.php.net/ob_get_contents
>
> Michal Chmielewski wrote:
>> I am not very familiar with PHP but the $html = <<< EOHTML line is
>> really making the HTML content be buried in the PHP code.
> > ...
>> I read a little about output buffering in PHP and this template seems
>> more logical to me and fixes these 2 issues.
>> Anything that I am missing ?
Re: Better template.php ? [message #581087 is a reply to message #18081] Tue, 14 November 2006 17:24 Go to previous message
Eclipse Webmaster is currently offline Eclipse WebmasterFriend
Messages: 607343
Registered: July 2009
Senior Member
Actually, most of the newer pages I create are set up for
multi-language/localized content:

template.php:
-- snip --
# Place your html content in a file called content/en_template.php
include($App->getLocalizedContentFilename());

# Generate the web page
$App->generatePage(...)

--snip--

Where all my HTML content lies in
content/[en|fr|de|etc...]_template.php, allowing for localized content.

D.



Denis Roy wrote:
> Indeed, Bjorn's use of the output buffer makes a much cleaner (and
> better) implementation. Most of our pages use it, but I have yet to
> update the templates.
>
> D.
>
>
>
> Bjorn Freeman-Benson wrote:
>> That is the way I write pages for the eclipse.org website. See for
>> example: /projects/europa.php
>> The only additional thing I use is:
>>
>> $html = ob_get_contents();
>> ob_end_clean();
>> $App->generatePage( ..., $html, ... );
>>
>> The ob_end_clean allows further code to write to the output stream
>> normally. See http://us3.php.net/ob_get_contents
>>
>> Michal Chmielewski wrote:
>>> I am not very familiar with PHP but the $html = <<< EOHTML line is
>>> really making the HTML content be buried in the PHP code.
>> > ...
>>> I read a little about output buffering in PHP and this template seems
>>> more logical to me and fixes these 2 issues.
>>> Anything that I am missing ?
Re: Better template.php ? [message #581101 is a reply to message #18069] Tue, 14 November 2006 18:29 Go to previous message
Michal Chmielewski is currently offline Michal ChmielewskiFriend
Messages: 58
Registered: July 2009
Member
Sounds good.
-m
Bjorn Freeman-Benson wrote:
> That is the way I write pages for the eclipse.org website. See for
> example: /projects/europa.php
> The only additional thing I use is:
>
> $html = ob_get_contents();
> ob_end_clean();
> $App->generatePage( ..., $html, ... );
>
> The ob_end_clean allows further code to write to the output stream
> normally. See http://us3.php.net/ob_get_contents
>
> Michal Chmielewski wrote:
>> I am not very familiar with PHP but the $html = <<< EOHTML line is
>> really making the HTML content be buried in the PHP code.
> > ...
>> I read a little about output buffering in PHP and this template seems
>> more logical to me and fixes these 2 issues.
>> Anything that I am missing ?
Previous Topic:How to get <ul> list elements with out dashed lines
Next Topic:HTTP Proxy and PHP ?
Goto Forum:
  


Current Time: Thu Apr 18 10:03:07 GMT 2024

Powered by FUDForum. Page generated in 0.02411 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top