Call separate header.txt admin

Helpdesk for my helpdesk software

Moderator: mkoch227

D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Call separate header.txt admin

Post by D12Eminem989 »

Is there a way to call a separate header.txt file in the admin panel and if so, can you post an example code. Reason I ask is the way I am setting it up is it calls php files from a parent directory and doesn't work correctly when viewed in admin panel.

Thanks in advance!
Last edited by D12Eminem989 on Mon Aug 13, 2012 5:35 am, edited 5 times in total.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Call separate header.txt admin

Post by Klemen »

You would need to modify this in "inc/header.inx.php"

Code: Select all

include(HESK_PATH . 'header.txt');
to say something like

Code: Select all

if (basename(dirname(__FILE__)) == 'admin')
{
	include(HESK_PATH . 'header_admin.txt');
}
else
{
	include(HESK_PATH . 'header.txt');
}
Didn't test it though.

However, your problem probably is you are using relative URLs in your header.txt, not absolute ones.

For example DON'T use this:

Code: Select all

<img src="images/test.jpg">
Use FULL URL instead:

Code: Select all

<img src="http://yourwebsite.com/images/test.jpg">
Then it should work fine both on customer side and 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
D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Re: Call separate header.txt admin

Post by D12Eminem989 »

That code didn't work.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Call separate header.txt admin

Post by Klemen »

Well, if you'd explain what exactly you are trying to do...
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
D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Re: Call separate header.txt admin

Post by D12Eminem989 »

I have an includes to a php file which sets navigation links. So adding ../../ will work but then guests wont see the navigation because it will be going back more directories.

So basically, I need a separate file called like you did with that above code, but it doesn't even call the file. Maybe the codes wrong?
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Call separate header.txt admin

Post by Klemen »

Perhaps you could use HESK_PATH constant for your includes?

Instead of

require('../../file.php');

require(HESK_PATH . 'file.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
D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Re: Call separate header.txt admin

Post by D12Eminem989 »

I would prefer your original method as your second method would require me to have double files which I don't want.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Call separate header.txt admin

Post by Klemen »

This works on my server:

Code: Select all

if (strpos(__FILE__, 'admin') !== false)
{
   include(HESK_PATH . 'header_admin.txt');
}
else
{
   include(HESK_PATH . 'header.txt');
}
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
D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Re: Call separate header.txt admin

Post by D12Eminem989 »

Interesting, that code doesn't seem to be working either. I have edited the "inc/header.inc.php". It still only pulls whats in "header.txt" in the admin panel and not "header_admin.txt".
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Call separate header.txt admin

Post by Klemen »

Did you rename the admin folder?

What does this code say on your server, if you save it as "test.php" and place in HESK folder?

Code: Select all

<?php echo __FILE__; ?>
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
D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Re: Call separate header.txt admin

Post by D12Eminem989 »

No, I did not rename the admin folder and the test file says the following:

/home/user/public_html/support/test.php
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Call separate header.txt admin

Post by Klemen »

As expected, so no idea why that code doesn't work for you.

Try turning Debug mode ON then change "include" to "require" and see if the script fails meaning the file is not there where it's supposed to be.

Other than that I would have to see your help desk live to be able to help further.
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
D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Re: Call separate header.txt admin

Post by D12Eminem989 »

Yes when I turn Debug mode ON, I just see the normal file not found error as well with changing include to require.

This is what my header.inc.php looks like:

Code: Select all

<?php
if (strpos(__FILE__, 'admin') !== false)
{
   include(HESK_PATH . 'header_admin.txt');
}
else
{
   include(HESK_PATH . 'header.txt');
}
?>
I am also using Hesk 2.4 if that makes a difference.
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Call separate header.txt admin

Post by Klemen »

The header_admin.txt should be in the same folder as "header.txt" for this to work, not inside "admin" folder!
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
D12Eminem989
Posts: 12
Joined: Fri Aug 10, 2012 12:28 pm

Re: Call separate header.txt admin

Post by D12Eminem989 »

That is correct, I have header_admin.txt inside the root of my Hesk installation. I have edited header.inc.php like you said in the first reply and added the code.

The code still only reads header.txt and not header_admin.txt like it should. Unless I am doing something wrong here?
Post Reply