Jump to content

need help with a file path to my css file


ricky spires

Recommended Posts

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 ????

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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

 

 

 

Link to comment
Share on other sites

<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?

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.