Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[phoenix-dev] A better way to write HTML editor friendly Phoenix page

Wow do I feel stupid. Ok, so you know how I complained that Phoenix was too hard to use because I couldn't use my HTML editor (FrontPage) to edit the files because the HTML was all contained in a giant variable? Well, with a little sleuthing in the PHP manual, I found out how to fix this.

Here is the way the pages are supposed to be written:
<?php                                                                                                                          require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");    require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php");     require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php");     $App     = new App();    $Nav    = new Nav();    $Menu     = new Menu();        include($App->getProjectCommon());    # All on the same line to unclutter the user's desktop'


    #
    # Begin: page-specific settings.  Change these.
    $pageTitle         = "Legal Resources";
    $pageKeywords    = "legal, documents, about";
    $pageAuthor        = "M. Ward Nov 18/05";
   
    # Add page-specific Nav bars here
    # Format is Link text, link URL (can be http://www.someothersite.com/), target (_self, _blank), level (1, 2 or 3)
    # $Nav->addNavSeparator("My Page Links",     "downloads.php");
    # $Nav->addCustomNav("My Link", "mypage.php", "_self", 3);
    # $Nav->addCustomNav("Google", "http://www.google.com/", "_blank", 3);

    # End: page-specific settings
    #
       
    # Paste your HTML content between the EOHTML markers!   
    $html = <<<EOHTML

    <div id="midcolumn">
    ...
    </div> 

EOHTML;

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

Here's what I changed it to previously (my changes in bold; notice the major chnage that I highlight with larger font)
<?php
    include($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/include-before-definitions.php");

$pageTitle         = "Proposals";
$pageKeywords    = "proposals";
$pageAuthor        = "Bjorn Freeman-Benson Nov 20/05";

    include($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/include-after-definitions.php");
?>

    <div id="maincontent">
    ...
  </div>
<?php
    include($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/include-end-of-page.php");
?>

Here is the new way:
<?php                                                                                                                          require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/app.class.php");    require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/nav.class.php");     require_once($_SERVER['DOCUMENT_ROOT'] . "/eclipse.org-common/system/menu.class.php");     $App     = new App();    $Nav    = new Nav();    $Menu     = new Menu();        include($App->getProjectCommon());    # All on the same line to unclutter the user's desktop'

$pageTitle         = "Technology Project";
$pageKeywords    = "technology";
$pageAuthor        = "Bjorn Freeman-Benson Nov 20/05";

ob_start();
?>       
    <div id="maincontent">
    ...
  </div>
<?php
    # Paste your HTML content between the EOHTML markers!   
    $html = ob_get_contents();
    ob_end_clean();

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

By using ob_start and ob_get_contents and ob_end_clean, I can still write the HTML in the WYSIWYG editor and I can still use the $App->generate call. This is great. We should change the standard help template (Denis, where is it?) to show people this way of doing page dev instead of having them do the "all the HTML in the variable" way.


Back to the top