Page 1 of 2

Call separate header.txt admin

Posted: Fri Aug 10, 2012 12:31 pm
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!

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 1:37 pm
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.

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 1:51 pm
by D12Eminem989
That code didn't work.

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 2:12 pm
by Klemen
Well, if you'd explain what exactly you are trying to do...

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 2:19 pm
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?

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 2:38 pm
by Klemen
Perhaps you could use HESK_PATH constant for your includes?

Instead of

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

require(HESK_PATH . 'file.php');

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 3:22 pm
by D12Eminem989
I would prefer your original method as your second method would require me to have double files which I don't want.

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 3:26 pm
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');
}

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 3:36 pm
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".

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 3:53 pm
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__; ?>

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 3:56 pm
by D12Eminem989
No, I did not rename the admin folder and the test file says the following:

/home/user/public_html/support/test.php

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 4:11 pm
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.

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 4:18 pm
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.

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 4:23 pm
by Klemen
The header_admin.txt should be in the same folder as "header.txt" for this to work, not inside "admin" folder!

Re: Call separate header.txt admin

Posted: Fri Aug 10, 2012 4:27 pm
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?