Welcome Guest, Not a member yet? Register   Sign In
Problem creating library
#1

[eluser]DanielWT[/eluser]
I'm having a problem with a libarary I created that when I call it it doesn't return anything. I just get a blank page. Can anyone offer an explaination as to why this may be happening?

Thanks
#2

[eluser]tonanbarbarian[/eluser]
Can you post the code from the controller that calls the library and the library itself so that we can see what it is doing
#3

[eluser]DanielWT[/eluser]
Gladly.

Controller:
(Library is in auto load.)

templatetest.php
Code:
<?

class Templatetest extends Controller {

    function index()
    {
        $this->template->main('top')
    }
}
?>

Library:
(Note some parts where removed and commented over to keep the site confidential as asked.)

Template.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Template {

    function main($part = '')
    {
        if($part == "top"){
        return '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8" /&gt;
&lt;link rel="stylesheet" type="text/css" href="/style.css" /&gt;
&lt;title&gt;/*title*/&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<table border="0" width="100%" cellpadding="5px">
<tr><td colspan="3" class="center">
<img src="/images/logotry1.jpg" alt=""/></td><td style="background-color:black;width:15%">
<p>ADZ!</p></td></tr>
<tr valign="top"><td class="side">
<div>
  <b class="newsbox">
  <b class="newsbox1"><b></b></b>
  <b class="newsbox2"><b></b></b>
  <b class="newsbox3"></b>
  <b class="newsbox4"></b>
  <b class="newsbox5"></b></b>

  <div class="newsboxfg">
  <div style="position:relative;width:95%;left:10px">
  <span style="font-size:25px">Community</span><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/">Home</a><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/">Forums</a><br/>
  <img src="/images/square.gif" class="square" alt="" />
  <a href="/submit">Submit an Update!</a><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/">Link here</a><br/>
  </div></div>

  <b class="newsbox">
  <b class="newsbox5"></b>
  <b class="newsbox4"></b>
  <b class="newsbox3"></b>
  <b class="newsbox2"><b></b></b>
  <b class="newsbox1"><b></b></b></b>
</div><br/>
<div>
  <b class="newsbox">
  <b class="newsbox1"><b></b></b>
  <b class="newsbox2"><b></b></b>
  <b class="newsbox3"></b>
  <b class="newsbox4"></b>
  <b class="newsbox5"></b></b>

  <div class="newsboxfg">
  <div style="position:relative;width:95%;left:10px">
  <span style="font-size:25px">Guides</span><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/quests">Quest Guides</a><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/areas">Area Guides</a><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/special">Special Guides</a><br/>
  </div></div>

  <b class="newsbox">
  <b class="newsbox5"></b>
  <b class="newsbox4"></b>
  <b class="newsbox3"></b>
  <b class="newsbox2"><b></b></b>
  <b class="newsbox1"><b></b></b></b>
</div><br/>
<div>
  <b class="newsbox">
  <b class="newsbox1"><b></b></b>
  <b class="newsbox2"><b></b></b>
  <b class="newsbox3"></b>
  <b class="newsbox4"></b>
  <b class="newsbox5"></b></b>

  <div class="newsboxfg">
  <div style="position:relative;width:95%;left:10px">
  <span style="font-size:25px">Database</span><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/npcs">NPCs</a><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/items">Items</a><br/>
  <img src="/images/square.gif" class="square" alt=""/>
  <a href="/monsters">Monsters</a><br/>
  </div></div>

  <b class="newsbox">
  <b class="newsbox5"></b>
  <b class="newsbox4"></b>
  <b class="newsbox3"></b>
  <b class="newsbox2"><b></b></b>
  <b class="newsbox1"><b></b></b></b>
</div>
</td>
<td colspan="2">';
    }elseif($part=='bottom'){
    return 'Bottom of template';
    }else{
    return 'No template found for that param.';
    }
    }
}
?&gt;

Only really included the top part until i could get it working.

All help is appreciated.
#4

[eluser]Nick Husher[/eluser]
Returning code isn't the same as printing it. Try:

Code:
echo $this->template->main('top');
#5

[eluser]DanielWT[/eluser]
Thanks Big Grin I'll try it.
#6

[eluser]DanielWT[/eluser]
It works! I'm so silly Tongue Thanks




Theme © iAndrew 2016 - Forum software by © MyBB