PHP in Public Header/Footer

Solutions for other advanced phplisters

PHP in Public Header/Footer

Postby Guest » 3:28am, Thu 15 Jan, 2009

Can I call php via include in the custom header/footer under configure?

Thanks,
M
Guest
 

Postby etechron » 2:12am, Tue 27 Jan, 2009

i want to know about this as well. I have used the forum search and looked through the document still have have not found an answer after extensive research. :?: :?: :?:
etechron
phpList newbie
 
Posts: 4
Joined: 2:06am, Tue 27 Jan, 2009

Postby Dragonrider » 6:32pm, Sun 01 Feb, 2009

I wouldn't have thought so, tho this is my own opinion. What you might have to consider is adding the php code to the actual header/footer file.

If you do, make sure you have a backup of your files before you start.
My sites:- http://wharfedalefestival.co.uk, http://ilkleygardeners.org.uk, http://emergencyaid.net, http://dragonrider.co.uk
Latest phpList version is now 3.0.12 (3 February 2015) and requires a minimum of MySQL 5.0 and PHP 5.3.x
Dragonrider
Moderator
 
Posts: 3460
Joined: 6:58am, Sun 02 Jul, 2006
Location: Ilkley, West Yorkshire, United Kingdom

PHP in header/footer SOLUTION

Postby etechron » 6:55pm, Mon 02 Feb, 2009

I am amazed about the horrible use of code on this project. It is not object oriented and the way how the code is done, just doesn't make sense.

Thank you developers for putting time into this project but the code could be improved upon in my opinion. There is nothing in this project that is 'reusable' in a sense of object oriented technology.

GOOD NEWS! After struggling of understanding the system, the bulk of the application is within index.php (atleast the client side of things)

Code: Select all
function get_include_contents($filename) {
   
    if (is_file($filename)) {
        ob_start();
        include $filename;
        $contents = ob_get_contents();
        ob_end_clean();
        return $contents;
    }
   
    return false;
}


You will want to put that function inside of index.php, I put mine on line 76 before

Code: Select all
include "admin/pagetop.php";


Places in index.php that say

Code: Select all
print $data["header"];

or
Code: Select all
$html .= $data["header"];

should be replaced with
Code: Select all
 print get_include_contents('config/header.php');

and
Code: Select all
 $html .= get_include_contents('config/header.php');

respectively. You will need to do this nearly a dozen times. Use the find ALL / replace ALL feature in Dreamweaver or your favorite app.

In addition, my header.php file looks as such
Code: Select all
   <php>include("../meta.php"); </php>
</head>

<body>
<div>

    <div>
      <php> include("../header.php"); </php>
   </div>
   

   <div>
   </div>
   
   <div>


my footer.php
Code: Select all
   </div>
    <div>
        <div>
             <php> include("../footer_right.php"); </php>
        </div>
       
        <div>
            <php> include("../footer_left.php"); </php>
        </div>
       
        <div>
            <div>
            Powered by phplist
            </div>
        </div>
    </div>
   
</div>
<php> include("../footer.php"); </php>
</body>
</html>


Remember, your header has to start with </head> since phplist generates the title tags for you (another thing which i modified on my install)

Must do this with the footer as well. I commented out the Powered By phplist and put it in my global footer so its in a different location than at the end of the content, so now its at the end of the page. You will see how i handled the credits to phplist on my footer instead of how the system normally does it.

Questions? Let me know.

(they wont allow me to post URLS since i dont have 10 posts! :o

Instead type in the URL bar,

etechrongroup com forward slash mailing
etechron
phpList newbie
 
Posts: 4
Joined: 2:06am, Tue 27 Jan, 2009

Postby SommerNyte » 7:26am, Tue 10 Feb, 2009

I, too, need to use php includes in my page templates.

I did everything you specified and effectively broke my site template. Then I realized you had created a new file called header.php in the lists/config folder and placed the code you'd normally enter in the config area in that file. Once I did that, it almost worked... the php include just prints on my screen, though, instead of actually including anything.

Then I saw that you were using <php> and </php> around your code, which this forum seems to automatically convert the true php tags to (I thought it was some special tag created within phpList that had to be used!).

Once I did all that, it worked fine. :)

By the way, he link you gave to your own site as an example doesn't work, nor does the "Newsletter" link I found on your site.
SommerNyte
PL Nut
 
Posts: 15
Joined: 11:00pm, Mon 01 Aug, 2005

Re: PHP in Public Header/Footer

Postby ijmilton » 2:10am, Thu 15 Mar, 2012

Thank you etechron!!!! For anyone still looking for this functionality, this WORKS using PHPlist 2.10.17. I wanted to clarify something that gave me trouble and hopefully make things easier to understand.

After making this modification, you will no longer edit the subscription page template through the web interface. You will need to create header.php and footer.php in your /phplist/config directory. You need to enter the respective header/footer template info in these 2 files instead of in the subscription config on your admin page. This is also where you will be placing your php includes, the whole point of this thread.

Knowing this, you should be able to follow etechron's post without problems. Enjoy!
ijmilton
phpList newbie
 
Posts: 2
Joined: 1:56am, Thu 15 Mar, 2012

Re: PHP in Public Header/Footer

Postby ijmilton » 4:12am, Sun 18 Mar, 2012

just realized some other changes need to be made.

In:
lists/index.php

change 3 instances of:
Code: Select all
$res .= $data["header"];


to:
Code: Select all
print get_include_contents('config/header.php');


In:
lists/admin/subscribelib2.php

change 2 instances of:
Code: Select all
print $subscribepagedata["header"];

to:
Code: Select all
print get_include_contents('config/header.php');


Make sure as before to DO THE SAME THING WITH FOOTER and you should be ready to go :-)
ijmilton
phpList newbie
 
Posts: 2
Joined: 1:56am, Thu 15 Mar, 2012

Re: PHP in Public Header/Footer

Postby timmeh83 » 8:34pm, Sun 18 Mar, 2012

Thank you all so much for this information. I managed to get most things working now.

Only the conformation and the unsubcribe functions keep ending up underneath my footer......
Is this a common problem? Or maybe i did something wrong?

i guess it is in these lines from index.php

$res = '<title>'.$GLOBALS["strConfirmTitle"].'</title>';
print get_include_contents('../header.php');
$res .= '<h2>'.$info.'</h2>';
$res .= $html;
$res .= "<P>".$GLOBALS["PoweredBy"].'</p>';
print get_include_contents('../footer.php');
return $res;
}

function unsubscribePage($id) {
global $data, $tables;
$res = '<title>'.$GLOBALS["strUnsubscribeTitle"].'</title>'."\n";
print get_include_contents('../header.php');

Thanks in advance,
Tim
timmeh83
phpList newbie
 
Posts: 2
Joined: 8:29pm, Sun 18 Mar, 2012


Return to Advanced Answers, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest