Jump to content

placeholders


atholon

Recommended Posts

I can`t figure this out...does anyone know what I am doing wrong. I am trying to make a place holder but it doesn`t work

 

<?php
class MasterPage
{
    var $title;
    var $bodyHtml;

    
    function MasterPage( $pathToHtml, $iTitle)
    {
        $this->title = $iTitle;
        $this->bodyHtml = readfile($pathToHtml);
    }
    
    function Render()
    {
        // replace placeholders
        print($this->bodyHtml);
        $this->bodyHtml = str_replace('{title}', $this->title, $this->bodyHtml);
        print($this->bodyHtml);

    }
}

?>

The call:

// Usage of MasterPage in a real script... (let's say in the /admin/index.php)
require('../includes/MasterPage.class');
$page = new MasterPage('../skins/defaultSkin/index.html', 'Admin Menu');

$something = "hey";

$page->Render();

Link to comment
Share on other sites

Ok that works...

 

how would I replace the text with an entire function?

 

Like this:

 

function index ()
{
echo (" 	      <table border=\"0\" align=\"center\" valign=\"center\" width=\"90%\" height=\"100%\" cellpadding=\"0\" cellspacing=\"5\">");
echo ("        <tr><td valign=\"middle\" width=\"250\">");
echo ("          <b>News/Article Options:</b><br>");
echo ("          1. <a href=\"./news.php?view=addnews\" class=\"somethingelse\">Create a new article</a> <br>");
echo ("          2. <a href=\"./news.php?view=list\"  class=\"somethingelse\">Manage articles</a>      <br>");
echo ("        </td>");
echo ("        <td valign=\"middle\" width=\"250\">");
echo ("          <b>Tutorial Options:</b><br>");
echo ("          1. <a href=\"./tutorials.php?view=submit\" class=\"somethingelse\">Create a new tutorial</a> <br>");
echo ("          2. <a href=\"$_SERVER[php_SELF]?view=addcat\" class=\"somethingelse\">Add a category</a> <br>   ");
echo ("          3. <a href=\"blank\" class=\"$_SERVER[php_SELF]?view=addsubcat\">Add a subcategory</a><br>");
echo ("          4. <a href=\"../tutorials/tutorials.php?view=theadminscreen\" class=\"somethingelse\">Tutorials waiting to be approved</a> <br>     ");
echo ("        </td></tr>");
echo ("        <tr><td valign=\"middle\" width=\"250\">");
echo ("          <b>Tutorial Options:</b><br>");
echo ("          1. <a href=\"./tutorials.php?view=submit\" class=\"somethingelse\">Create a new tutorial</a> <br>");
echo ("          2. <a href=\"blank\" class=\"somethingelse\">Add a category</a> <br>   ");
echo ("          3. <a href=\"blank\" class=\"somethingelse\">Add a subcategory</a><br>");
echo ("        </td>");
echo ("        <td valign=\"middle\" width=\"250\">");
echo ("          <b>Main Page Options:</b><br>");
echo ("          1. <a href=\"$_SERVER[php_SELF]?view=mplinks\" class=\"somethingelse\">Change main page pictures and links</a> <br>");
echo ("        </td></tr>");
echo ("  	<tr><td valign=\"middle\" width=\"250\">");
echo ("          <b>Side Options:</b><br>");
echo ("          1. <a href=\"blank\" class=\"somethingelse\">Create a new review</a> <br>");
echo ("          2. <a href=\"blank\" class=\"somethingelse\">Edit existing review</a> <br>   ");
echo ("          3. <a href=\"blank\" class=\"somethingelse\">Delete review</a><br>");
echo ("        </td>");
echo ("        <td valign=\"middle\" width=\"250\">");
echo ("          <b>User Options:</b><br>");
echo ("          1. <a href=\"blank\" class=\"somethingelse\">Ban user</a><br>");
echo ("        </td></tr>");
echo ("  	<tr><td valign=\"middle\" width=\"250\">");
echo ("          <b>File Management:</b><br>");
echo ("          1. <a href=\"$_SERVER[php_SELF]?view=fileupload\" class=\"somethingelse\">Upload a file</a> <br>");
echo ("          2. <a href=\"blank\" class=\"somethingelse\">Erase a file</a> <br>   ");
echo ("        </td>");
echo ("        <td valign=\"middle\" width=\"250\">");
echo ("          <b>User Options:</b><br>");
echo ("          1. <a href=\"blank\" class=\"somethingelse\">Administrate User Ratings</a><br>");
echo ("        </td></tr>");
echo ("        </table>");
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.