ricky spires Posted October 7, 2011 Share Posted October 7, 2011 Hello. if i use a function to my layouts header file it works but if i try the same code to call my css file it doesn't work. any ideas? this is the code that gets the layout and works in the initialize file i have a path to the template: <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('ADMIN_TEMP') ? null : define('ADMIN_TEMP', $_SERVER['DOCUMENT_ROOT'].DS.'djsonrotation'.DS.'admin'.DS.'templates'); then i have a function that looks for the layouts (header, footer etc) inside of the template set in the database 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); } then i call the layout on the page <?php include_admin_layout('header.php'); ?> THAT ALL WORKS. IT GETS THE HEADER FILE FROM INSIDE admin/templates/template name = ($name)/layouts/header.php this is the code that im trying to use to get the css file that does not work the initialize file is the same: <?PHP defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR); defined('ADMIN_TEMP') ? null : define('ADMIN_TEMP', $_SERVER['DOCUMENT_ROOT'].DS.'djsonrotation'.DS.'admin'.DS.'templates'); then i have a function that looks for the css file inside template/css/ function include_admin_css($css){ $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.'css'.DS.$css); } then i call the css on the page the same as i did for layouts <link type="text/css" rel="stylesheet" href="<?php include_admin_css('styles.css'); ?>" media="screen,projection,tv"/> THAT DOES NOT WORK BUT ITS ALL THE SAME ????? why is that ???? Quote Link to comment https://forums.phpfreaks.com/topic/248654-need-help-with-a-file-path-to-my-css-file/ Share on other sites More sharing options...
silkfire Posted October 7, 2011 Share Posted October 7, 2011 any errors? Quote Link to comment https://forums.phpfreaks.com/topic/248654-need-help-with-a-file-path-to-my-css-file/#findComment-1277055 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2011 Share Posted October 7, 2011 First problem - Using echo include(... ...); will echo a true/false value (1/null) (or a value you return inside the included file) followed by any output that the included file produces. Using echo in front of the include() statement does not echo the content that is being included. Remove the echo (you are likely getting a '1' echoed in the content.) Second problem - BUT ITS ALL THE SAME. No it's not. <?php include_admin_layout('header.php'); ?> <--- that includes the header.php file into the calling script and outputs anything that the header.php file produces. <link type="text/css" rel="stylesheet" href="some_URL_of_a_css_file" media="screen,projection,tv"/> <--- that expects a URL to an external css file, not the actual css. If you instead used inline css, what you are trying would work. Quote Link to comment https://forums.phpfreaks.com/topic/248654-need-help-with-a-file-path-to-my-css-file/#findComment-1277056 Share on other sites More sharing options...
ricky spires Posted October 7, 2011 Author Share Posted October 7, 2011 Thanks for your replies. silkfire: any errors? nope. no errors. (you are likely getting a '1' echoed in the content.) yes, thanks. i was wondering what that was. If you instead used inline css, what you are trying would work. HOW ?? i know what in line css im trying to get it to look for a different css file every time. each template has its own css file and it looks for the css file for which ever template is active i thought you might mean <style> <?php include_admin_css('styles.css'); ?> </style> but thats not it ????? hang on - i thought i was looking for an external css file. the page is admin/index.php (for example) and the css file is located in admin/templates/template_name/css/styles.css Quote Link to comment https://forums.phpfreaks.com/topic/248654-need-help-with-a-file-path-to-my-css-file/#findComment-1277068 Share on other sites More sharing options...
PFMaBiSmAd Posted October 7, 2011 Share Posted October 7, 2011 <style type="text/css"> <?php include_admin_css('styles.css'); ?> </style> ^^^ If that doesn't work, you will need to be specific about what it actually outputs into the 'view source' of the page in the browser and/or what it does do vs what you expect. Is the actual path/filename that is produced by - ADMIN_TEMP.DS.$name.DS.'css'.DS.$css what you expect and it exists? Quote Link to comment https://forums.phpfreaks.com/topic/248654-need-help-with-a-file-path-to-my-css-file/#findComment-1277076 Share on other sites More sharing options...
ricky spires Posted October 7, 2011 Author Share Posted October 7, 2011 GREAT. i think the problem was that the css was being called in the layouts header and the index. i removed it from the index and it worked using <style type="text/css"> <?php include_admin_css('styles.css'); ?> </style> THANKS Quote Link to comment https://forums.phpfreaks.com/topic/248654-need-help-with-a-file-path-to-my-css-file/#findComment-1277081 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.