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
https://forums.phpfreaks.com/topic/89315-placeholders/
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
https://forums.phpfreaks.com/topic/89315-placeholders/#findComment-457359
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.