Different CSS for Admin?

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
JamesN
Posts: 7
Joined: Tue Apr 23, 2013 10:50 am

Different CSS for Admin?

Post by JamesN »

I've setup the hesk software on my site customizing the frontend user side. The problem with this is that by doing this, its made a mess of the admin side.

I was hoping to get around this by using the default css file and a blank header/footer file for the admin area.

How could I do this?
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Different CSS for Admin?

Post by Klemen »

You could try changing this in inc/header.inc.php:

Code: Select all

<?php echo HESK_PATH; ?>hesk_style_v24.css
To say:

Code: Select all

<?php
if (basename(__DIR__) == 'admin') {define('IS_ADMIN', true);}
else {define('IS_ADMIN', false);}

echo HESK_PATH . (IS_ADMIN ? 'hesk_style_v24_ADMIN.css' : 'hesk_style_v24.css');
?>
(where "hesk_style_ADMIN_v24.css" is the CSS file to use for admin panel).

And for header/footer you could paste something like this inside each text file:

Code: Select all

<?php
if (empty(IS_ADMIN))
{
?>

YOUR HEADER/FOOTER CODE HERE

<?php
}
?>
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
JamesN
Posts: 7
Joined: Tue Apr 23, 2013 10:50 am

Re: Different CSS for Admin?

Post by JamesN »

Thanks for coming back to me. It isnt working though, and just displays blank pages everywhere when I make the changes. It seems to be to do with the footer and header because once I revert those files everything returns to normal.

Does this look correct?

This is how my header.inc file

Code: Select all

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title><?php echo (isset($hesk_settings['tmp_title']) ? $hesk_settings['tmp_title'] : $hesk_settings['hesk_title']); ?></title>
	<meta http-equiv="Content-Type" content="text/html;charset=<?php echo $hesklang['ENCODING']; ?>" />
	<link href="<?php
if (basename(__DIR__) == 'admin') {define('IS_ADMIN', true);}
else {define('IS_ADMIN', false);}

echo HESK_PATH . (IS_ADMIN ? 'hesk_style_v24_ADMIN.css' : 'hesk_style_v24.css');
?>" type="text/css" rel="stylesheet" />
	<link rel="stylesheet" type="text/css" href="../css/portal.css">
	<script language="Javascript" type="text/javascript" src="<?php echo HESK_PATH; ?>hesk_javascript_v24.js"></script>

My header txt file

Code: Select all

<?php
if (empty(IS_ADMIN))
{
?>


	<div class="main_content">

	<?php include ("../top.php"); ?>


		<div class="portal_content">
			<!-- VERTICAL AD -->
			<div class="ad_160_600">
				<?php include ("../160x600.php"); ?>
			</div>

				<div class="wide_column">
					<div class="wide_column_content">


<?php
}
?>
and my footer

Code: Select all

<?php
if (empty(IS_ADMIN))
{
?>



						<?php include ("468x90.php"); ?>
				 </div>
			</div>
		</div>
		<div style="clear:both"></div>
	</div>

	<?php include ("../bottom.php"); ?>

	</body>
	</html>

<?php
}
?>
Thanks for your help, appreciate it :)
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Different CSS for Admin?

Post by Klemen »

Never mind, my error.

Try this instead:

header.inc.php

Code: Select all

<?php
if (strpos($_SERVER['PHP_SELF'], '/admin') !== false) {define('IS_ADMIN', true);}

echo HESK_PATH . (defined('IS_ADMIN') ? 'hesk_style_v24_ADMIN.css' : 'hesk_style_v24.css');
?>
header/footer.txt

Code: Select all

<?php
if (defined('IS_ADMIN'))
{
?>

YOUR CODE HERE

<?php
}
?>
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
JamesN
Posts: 7
Joined: Tue Apr 23, 2013 10:50 am

Re: Different CSS for Admin?

Post by JamesN »

Thanks for that. The CSS part is working fine now, but the header/footer is broken.

This is my header file as an example. I take out the condition if and it displays fine, so I know its that.

Code: Select all

<?php
if (defined('IS_ADMIN'))
{
?>


	<div class="main_content">

	<?php include ("../top.php"); ?>


		<div class="portal_content">
			<!-- VERTICAL AD -->
			<div class="ad_160_600">
				<?php include ("../160x600.php"); ?>
			</div>

				<div class="wide_column">
					<div class="wide_column_content">


<?php
}
?>
JamesN
Posts: 7
Joined: Tue Apr 23, 2013 10:50 am

Re: Different CSS for Admin?

Post by JamesN »

It seems I don't have to worry though, the header/footer files aren't showing in the admin panel anyway :)

Thanks again for your help! :)
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Different CSS for Admin?

Post by Klemen »

This will show your code in admin pages only:

Code: Select all

if (defined('IS_ADMIN'))
Changing it to this will show for customers only:

Code: Select all

if ( ! defined('IS_ADMIN'))
This will let you use a custom header for both:

Code: Select all

<?php
if (defined('IS_ADMIN'))
{
?>
CODE FOR ADMIN PANEL HERE
<?php
}
else
{
?>
CODE FOR CUSTOMER SIDE HERE
<?php
}
?>
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
JamesN
Posts: 7
Joined: Tue Apr 23, 2013 10:50 am

Re: Different CSS for Admin?

Post by JamesN »

Thanks so much :)
JamesN
Posts: 7
Joined: Tue Apr 23, 2013 10:50 am

Re: Different CSS for Admin?

Post by JamesN »

It seems I spoke too soon :(

See these two screenshots. It's fine on the main menu of the admin area, but as soon as I go into a ticket there, it doesn't pick it up properly with the header/footer. The interesting thing is though, the rest of the admin section is fine, its just the ticketing section.

Screenshots of Pages:

http://s20.postimg.org/jwf0a47ft/mainmenu.jpg

http://s20.postimg.org/apwpmu27d/ticket.jpg

Sourcecode of Pages:

http://s20.postimg.org/9owgxpl7x/mainmenu_source.jpg

http://s20.postimg.org/vpctec3vx/ticket_source.jpg

Any ideas?

header

Code: Select all

<?php
if (!defined('IS_ADMIN'))
{
?>


	<div class="main_content">

	<?php include ("../top.php"); ?>


		<div class="portal_content">
			<!-- VERTICAL AD -->
			<div class="ad_160_600">
				<?php include ("../160x600.php"); ?>
			</div>

				<div class="wide_column">
					<div class="wide_column_content">


<?php
}
?>
footer

Code: Select all

<?php
if (!defined('IS_ADMIN'))
{
?>



						<?php include ("../468x90.php"); ?>
				 </div>
			</div>
		</div>
		<div style="clear:both"></div>
	</div>

	<?php include ("../bottom.php"); ?>

	</body>
	</html>
<?php
}
?>
Klemen
Site Admin
Posts: 10147
Joined: Fri Feb 11, 2005 4:04 pm

Re: Different CSS for Admin?

Post by Klemen »

How about if you change

Code: Select all

strpos($_SERVER['PHP_SELF'], '/admin')
to

Code: Select all

strpos($_SERVER['PHP_SELF'], 'admin')
?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
JamesN
Posts: 7
Joined: Tue Apr 23, 2013 10:50 am

Re: Different CSS for Admin?

Post by JamesN »

Perfect now, thanks again :)
Post Reply