Jump to content

[SOLVED] this one should be fun.


severndigital

Recommended Posts

OK ..

 

I have a template.php included in an index.php file, that shows certain divs based off of variables set in the index.php.

 

I would like to control what shows up in those divs using a database table. I'll show you what i have so far.

 

//index.php

switch($view){

default: 
$topNav = 1;
$leftNav = 0;
$rightNav = 0;
$content = '/login/login.php';
break;

include_once 'template.php';


//the template file
$centerStyle = '';
$topString = '';
if($incTop == 1){
	$topString = '
        <div id="tmcTopNav">
        	' . importModules(2) . '
	</div>';
}		

 

the template file goes on to include all of the normal html information and then gets to where it would include the divs ....

 


<?php echo $topString; ?>

 

What i would like to do is write a function that looks for all the files that should go into the database. and then puts the correct file where it needs to go.

 

I have the function built, but i don't know how to include the file(s) so that they don't show up in the top left of the page.

 

//function so far.
function importModules($location)
{
//retrieve all active modules
$dBase = new pgConnect();
	$modules = $dBase->retAssoc("SELECT name FROM modules WHERE active='1' AND location='$location'");


for($i = 0; $i <count($modules); $i++){
	include_once MOD_DIR . $modules[$i]['name'] . '/' . $modules[$i]['name'] . '.php; ?>';
}

}

 

does anyone have any suggestions??

Thanks,

-C

 

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/142806-solved-this-one-should-be-fun/
Share on other sites

Well after a few hours of working through it on paper i was able to apply a solution to this. Gonna post it here for two reasons.

 

1. in the off change someone else will need it.

2. in case i forget what i did.

 

so

 

in the template file i did this

if($topNav == 1){ //area is turned on
$topString = '<div id="topNav">';
}

$endString = '</div>';


if(!empty($topString){
echo $topString;
includeModules(2);
echo $endString;
}

 

that seemed to do the trick.

 

-C

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.