iconicCreator Posted February 4, 2009 Share Posted February 4, 2009 I have been experimenting with PHP include files. I was also tried to add images to the include file. Eg. I created a footer and added a back ground image to the div tag holding the footer. Now when I add the include file to the index page, the "text" shows up but not the graphic. Just curious, if you can add a graphic and style with CSS, is this possible? Thanks everyone. IC Quote Link to comment Share on other sites More sharing options...
flyhoney Posted February 4, 2009 Share Posted February 4, 2009 Yes you definitely can. I would need to see your code as to why this isn't working. Is this what you are talking about? file1.php <?php $foo = 'bar'; ?> <html> <head> <title>Hello World</title> </head> <body> hello <?php include 'footer.php'; ?> footer.php World </body> </html> Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted February 4, 2009 Author Share Posted February 4, 2009 Yes you definitely can. I would need to see your code as to why this isn't working. Is this what you are talking about? file1.php <?php $foo = 'bar'; ?> <html> <head> <title>Hello World</title> </head> <body> hello <?php include 'footer.php'; ?> footer.php World </body> </html> This is the include file with no graphic, just wrapped up in Html tags. <div> <p>© <?php ini_set('date.timezone', 'Europe/London'); $startYear = 2006; $thisYear = date('Y'); if ($startYear == $thisYear) { echo $startYear; } else { echo "{$startYear}-{$thisYear}"; } ?> Patrick Judson</p> </div> Now I added classes to the paragraph tag and the div tag and added the image with CSS. Like this: <style type="text/css"> .footer { background-image: url(../testing_images/footerImage.png); height: 40px; background-repeat: no-repeat; background-position: center bottom; width: 780px; background-color: #EDF5F7; } .copyright { margin: 0px; padding-top: 6px; padding-right: 0px; padding-bottom: 0px; padding-left: 20px; } </style> <div class="footer"> <p class="copyright">© <?php ini_set('date.timezone', 'Europe/London'); $startYear = 2006; $thisYear = date('Y'); if ($startYear == $thisYear) { echo $startYear; } else { echo "{$startYear}-{$thisYear}"; } ?> Patrick Judson</p> </div> Quote Link to comment Share on other sites More sharing options...
flyhoney Posted February 4, 2009 Share Posted February 4, 2009 <style> tags are technically supposed to be within the <head> tag, but I think will usually work outside of that. Try moving the styles to the <head> tag. Also, what does the source of the page look like? Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted February 4, 2009 Author Share Posted February 4, 2009 This is the complete index page that contained the footer include file at the bottom Now The entire page is attached to an external style sheet. So I also placed the style/CSS for the footer include file into the external style sheet. It still doesn't work. Anyway, here's the code: <!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Japan Journey</title> <link href="journey.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> <div id="header"> <h1>Japan Journey </h1> </div> <div id="wrapper"> <?php include('includes/menu.inc.php'); ?> <div id="maincontent"> <h1>A journey through Japan with PHP </h1> <p>Ut enim ad minim veniam, quis nostrud exercitation consectetur adipisicing elit. Velit esse cillum dolore ullamco laboris nisi in reprehenderit in voluptate. Mollit anim id est laborum. Sunt in culpa duis aute irure dolor excepteur sint occaecat.</p> <div id="pictureWrapper"><img src="testing_images/basin.jpg" alt="Water basin at Ryoanji temple" width="350" height="237" class="picBorder" /></div> <p>Eu fugiat nulla pariatur. Ut labore et dolore magna aliqua. Cupidatat non proident, quis nostrud exercitation ut enim ad minim veniam.</p> <p>Consectetur adipisicing elit, duis aute irure dolor. Lorem ipsum dolor sit amet, ut enim ad minim veniam, consectetur adipisicing elit. Duis aute irure dolor ut aliquip ex ea commodo consequat.</p> <p>Quis nostrud exercitation eu fugiat nulla pariatur. Ut labore et dolore magna aliqua. Sed do eiusmod tempor incididunt velit esse cillum dolore ullamco laboris nisi.</p> </div> <?php include('includes/footer.inc.php'); ?> </div> </body> </html> Quote Link to comment Share on other sites More sharing options...
flyhoney Posted February 4, 2009 Share Posted February 4, 2009 What does the output look like? Quote Link to comment Share on other sites More sharing options...
iconicCreator Posted February 4, 2009 Author Share Posted February 4, 2009 What does the output look like? Well it's working now. This is what I did. Attached the the image to the <div> tags in the footer.inc.php file. I placed the CSS file in the external CSS file and attached the external file to the head of the pages that contained the footer. The reason it wasn't working is because I was not pointing the footer style attribute to the right path for the image. The only problem is. I have to attached any html tags applied to the include files which has styling attached with the footer file. Lets say wanted to add the footer to the index page with a background. Instead of inserting this: <?php include('includes/footer.inc.php'); ?> I would have to add this: <div class="addBackground"> <?php include('includes/footer.inc.php'); ?> </div> This way the background image gets attached with the include footer. Thanks for all your efforts and time. IC Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.