Jump to content

help needed with a function


ricky spires

Recommended Posts

hello.

 

im trying to write a function that sets the file path depending on what it pulls from the database

 

i have 2 databases

 

1 called "templates" which has a list of template names with there id's

and

1 called "basicSetting" which sets the active and default templates.

 

 

in the template db i have

id      name        type

id1    = template1    admin

id2    = template1    main

id3    = template1    main

 

 

in basic settings i have set

 

activeAdminTemp_id = 1

defaultAdminTemp_id = 1

activeTemp_id = 2

defaultTemp_id = 2

 

 

 

the path should be something like this

include(SITE_ROOT.DS.'GET TYPE/templates/GET TEMPLATE FOLDER NAME'.DS.GET TEMPLATE NAME.php);

 

 

SITE_ROOT = www.sitename.com/

 

GET TYPE    = /admin or in the main root

 

/templates/ = where the templates are stored

 

GET TEMPLATE FOLDER NAME = the name of the template is the same as the folder name

 

GET TEMPLATE NAME.php; = the name of the template.php

 

 

 

 

 

this is what i have in my functions file


function include_templates(){

$tempBS = basicSettings::find_all();

       //SHOULD GET THESE VALUES
$tempBS->id."<br />";
$tempBS->activeAdminTemp_id."<br />";
$tempBS->defaultAdminTemp_id.'<br/>';
$tempBS->activeTemp_id.'<br/>';
$tempBS->defaultTemp_id.'<br/>';



$temp = Templates::find_all();

        //SHOULD GET THESE VALUES
$temp->id."<br />";
$temp->name."<br />";
$temp->type.'<br/>';

}

 

now i need to add into my function something like this ... but im not sure.

 

$sql = "SELECT * FROM templates WHERE id='".$tempBS->id."'";

echo include(SITE_ROOT.DS.'.$temp->type./templates/'.$temp->name.''.DS.'temp->name.''.php');	

 

 

but that i not working.

 

please help

 

thanks

rick

Link to comment
Share on other sites

 

 

FIXED IT

 


function include_layout($layout){

$tempBS = basicSettings::find_by_id(1);
$TID = $tempBS->activeTemp_id;

$tempID = Templates::find_by_id($TID);
$name = $tempID->name;

	echo include(TEMP.DS.$name.DS.'layouts'.DS.$layout);
}



function include_admin_layout($layout){

$tempBS = basicSettings::find_by_id(1);
$TaID = $tempBS->activeAdminTemp_id;

$tempID = Templates::find_by_id($TaID);
$name = $tempID->name;

  	echo include(ADMIN_TEMP.DS.$name.DS.'layouts'.DS.$layout);

}

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.