Jump to content

[SOLVED] Can PHP include files contained graphics?


iconicCreator

Recommended Posts

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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>

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.