help please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy

    help please

    new to this and me and classes have never mixed well, im getting no errors
    but the only thing displaying is the copyright at the bottom of the page

    Anyone tell me whats wrong?


    Home.php_______ ______________


    <?php
    require('includ es/page.inc');
    $homepage = new page();

    $homepage ->SetContent('<t able width="95%" height="239" border="0"
    align="center" cellpadding="0" cellspacing="0" >\n
    <tr>\n<td width="120" height="69" bgcolor="#99CC0 0"
    align="center"> jhg </td>\n <td>this was inherited</td>\n</tr>
    </table>'
    );

    $homepage->Display();
    ?>


    Page.inc_______ _______________ _

    <?php
    //page class
    class page
    {
    var $content;
    var $title ='childhood memories';
    var $keywords='chil dhood memories, peoples childhood of days gone by';


    // class functions
    function SetContent($new content)
    {
    $this->content = $newcontent;
    }

    function SetTitle($newti tle)
    {
    $this->title = $newtitle;
    }

    function SetKeywords($ne wkeywords)
    {
    $this->keywords = $newkeywords;
    }

    function DisplayHeader()
    {
    ?>
    <table width="95%" height="87" border="0" align="center" cellpadding="0"
    cellspacing="0" >
    <tr bgcolor="#99CC0 0">
    <td height="87">&nb sp;</td>
    <td width="745" height="87" bgcolor="#99CC0 0">&nbsp;</td>
    </tr>
    </table>
    <?php
    }


    function display()
    {
    echo "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01
    Transitional//EN\">\n<html>\n <head>";
    $this->DisplayTitle() ;
    $this->DisplayKeyword s();
    $this->DisplayStyles( );
    echo "</head>\n<body\n" ;
    $this->DisplayHeader( );
    $this->content;
    echo "<center>&copy; 2004 Jarrowonline</center>";
    echo "</body>\n</html>";
    }



    function DisplayTitle()
    {
    echo'<title> $this->$title</title>';
    }

    function DisplayKeywords ()
    {

    echo "<META name=\"keywords \" content=\"$this->keywords\">" ;
    }

    function DisplayStyles()
    {
    echo '<link href=\"css/style.css\" rel=\"styleshee t\" type=\"text/css\">';
    }


    function IsURLCurrentpag e()
    {
    if(strpos($GLOB ALS['SCRIPT_NAME'],$url)==false)
    {
    return false;
    }
    else
    {
    return true;
    }
    }


    }
    ?>


    _______________ _______________ ______

    TIA


  • Janwillem Borleffs

    #2
    Re: help please

    Andy wrote:[color=blue]
    > new to this and me and classes have never mixed well, im getting no
    > errors but the only thing displaying is the copyright at the bottom
    > of the page
    >[/color]

    Add a new method DisplayContent which looks like this:

    function DisplayContent( ) {
    print $this->content;
    }

    Then replace:

    function display() {
    ...
    $this->content;
    ...
    }

    with:

    function display() {
    ....
    $this->DisplayContent ();
    ....
    }
    [color=blue]
    > function IsURLCurrentpag e()
    > {
    > if(strpos($GLOB ALS['SCRIPT_NAME'],$url)==false)
    > {
    > return false;
    > }
    > else
    > {
    > return true;
    > }
    > }
    >[/color]

    This can be written as follows (which is shorter):

    function IsURLCurrentpag e() {
    return strpos($GLOBALS['SCRIPT_NAME'], $url) !== false;
    }

    (Also notice the double equal signs, which ensure that 0 isn't validated as
    false)


    JW



    Comment

    • Janwillem Borleffs

      #3
      Re: help please

      Janwillem Borleffs wrote:[color=blue]
      > Andy wrote:[color=green]
      >> new to this and me and classes have never mixed well, im getting no
      >> errors but the only thing displaying is the copyright at the bottom
      >> of the page
      >>[/color][/color]

      Also, replace the DisplayTitle function with following:

      function DisplayTitle() {
      echo "<title>$th is->title</title>";
      }

      In the original function, you are using single quotes, which causes
      $this->title not to be parsed but to be taken literal and printed as such.


      JW



      Comment

      Working...