ricky spires Posted October 6, 2011 Share Posted October 6, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248581-help-needed-with-a-function/ Share on other sites More sharing options...
ricky spires Posted October 7, 2011 Author Share Posted October 7, 2011 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); } Quote Link to comment https://forums.phpfreaks.com/topic/248581-help-needed-with-a-function/#findComment-1276713 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.