can't make text fit in..

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

can't make text fit in..

Post by IAD »

Hey guys,

I'm working on an admin panel, and for the first time i wanted to use Templates.
I built a function that i'll replace the word "#pages" with it, and inside this function there's a switch().
When i'm replacing it, it won't show up instead of the "#pages" but will show up in the top of the page.

The class:

Code: Select all

<?Php

//-----------------------------------------------------------------
//	Author: Tal Gleichger
//-----------------------------------------------------------------
//	Company Name: IAD
//-----------------------------------------------------------------
//	Date Started: 9:43 PM 12/28/2005
//-----------------------------------------------------------------
//	Date Updated: _____Never_____
//-----------------------------------------------------------------

/*****************************************************************************
	All Rights Resered to IAD & GTM IL LTD 
	Any Code Copying is agains the law!
	Any Rights deletion is recoreded and will be repot!
*****************************************************************************/


	class adminTemplates{

				//----------------------------------------------
			// Actions: 
			//
			// 1) Getting HTML code
			// 2) Replacing HTML outputs
			// 3) Returning HTML only output
		//
		//----------------------------------------------

		private $tplfile; 
		private $navifile;
		private $rightsfile;
		private $doReplace;
		private $doOutput;
		public 	$template;
		public	$doGetLogo;
		public	$doGetNavi;
		public	$makeFopen_index;
		public	$makeFopen_navi;
		public	$makeFopen_rights;
		public	$getNavi;
		public	$getRights;


		public function getPages(){

			switch(@($_GET['a'])){

				case 'test':
					require "sources/admin/TPL/admin.css";
				break;

			}
			

		}

		public function createReplace($tplfile,$navi,$rights){
		
			//--
			// Opening the File and Getting Html inputs
			//--
	
			$this -> tplfile = $tplfile;
			$this -> navifile = $navi;
			$this -> rightsfile = $rights;
			
				$this -> makeFopen_index = fopen($this -> tplfile,'r+');
				$this -> makeFopen_navi = fopen($this -> navifile,'r+');
				$this -> makeFopen_rights = fopen($this -> rightsfile,'r+');

				$this -> template = fread($this -> makeFopen_index,filesize($tplfile));
				$this -> getNavi = fread($this -> makeFopen_navi,filesize($navi));
				$this -> getRights = fread($this -> makeFopen_rights,filesize($rights));

				//--
				// Replacing special chars and getting other file's instead
				//--	

				$this -> doGetLogo = str_replace('#logo','<img src="sources/admin/TPL/logo.jpg" alt="" />',$this -> template);
				$this -> doGetNavi = str_replace('#navi',$this -> getNavi,$this -> doGetLogo);
				$this -> doGetPages = str_replace('#pages',$this -> getPages(),$this -> doGetNavi);
				$this -> doGetRights = str_replace('#rights',$this -> getRights,$this -> doGetPages);

					$this -> doGetContents = $this -> doGetRights;

				//--
				// Finishing and returning the doGetContents
				//--
					
					return $this -> doGetContents;
		}

	}

?>
The function: getPages(); will return it contents in the top of the page, above the logo.


Marry christmas [did i wrote it correctly? :P] and happy hanukka, Tal.
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Post by IAD »

Anyone?
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I don't understand... what's your question?
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Post by IAD »

i'll explain:

You see the function getPages?

I want to replace the word "#pages" with it, i mean that in index.tpl, the word "#pages" will be replace with that function.

So what's the problem?

I got this TPL file:

Code: Select all

<table id="adminTable">
	<tr>
		<td class="logo" colspan="2">#logo</td>
	</tr>
	<tr>
		<td class="navi" valign="top">#navi</td>
		<td class="pages" valign="top">#pages</td>
	</tr>
	<tr>
		<td colspan="2">
			<div class="row1">
			#rights
			</span>
		</td>
	</tr>
</table>
See "#pages"? getPages(); will be there, and when i'm typing "?a=test" it won't print the admin.css in the <Td> but above the logo, above all the table.


Got it?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

I'm assuming the get_pages method is getting it's contents from an output buffer? That is probably your issue
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Post by IAD »

not realy, getPages is a function that inside theres a switch costructor that will make the whol "?a
..."

and the problem that it shows the files above the table when it need to be in a colume (#pages).
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

ah, I wasn't even paying attention to your code... well what you need to do is have your function return the contents of that file, rather then output them, we do that with a buffer which means it takes all of the output and stores it somewhere where we can get to it and then decide what to do, in this case we simply start the buffer, output the contents of admin.css, then the ob_get_clean() function returns the buffer, then turns off the output buffering

Code: Select all

public function getPages(){
	ob_start();
	switch(@($_GET['a'])){
		case 'test':	require "sources/admin/TPL/admin.css";	break;
		default:	echo 'Invalid request'; break;
	}
	return(ob_get_clean());
}
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Post by IAD »

Ohhh man you're the best!

Thanks man!
Post Reply