-
Include HTML inside PHP
Hi guys.
So I created a sidebar (sidebar.html), my sidebar is in html and I want to include it to my footer.php file.
First of all you cant include an html file using
PHP Code:
include 'sidebar.html';
(at least it doesn't work for me..)
But thats okay, I could use numbers of other codes, but I cant since I have another function, here is my function;
PHP Code:
<?php
if (isLoggedIn() == true)
<link rel="text" type="text" href="sidebar.html" />
?>
This mean that I only want to show the sidebar if the user is logged in, probably you all noticed that, but its better be specific than let people wonder..:P
When I use this code I get unexpected '<'
I also tried;
PHP Code:
<?php
if (isLoggedIn() == true)
{
?>
<link rel="text" type="text" href="sidebar.html" />
<?php
}
?>
Then I get not error, but the file isn't included either :S
Is there other ways I could include this file? I still want it to be shown only if logged in too...
-
Actually you CAN include an .html file like you have in your first example. Something else must be wrong with your code.
-
Well... Heres my code;
PHP Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>My Sidebar</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<!-- Docking boxes (dbx) -->
<script type="text/javascript" src="functions/dbx.js"></script>
<!-- dbx configuration script -->
<script type="text/javascript" src="functions/dbx-key.js"></script>
<!-- dbx stylesheet -->
<link rel="stylesheet" type="text/css" href="stylesheet.css" media="screen, projection" />
</head>
<body>
<div id="purple-outer">
<div class="dbx-group" id="purple">
<div class="dbx-box">
<h3 class="dbx-handle" title="Example1">Example1</h3>
<ul class="dbx-content">
<li><a href="/example2/">Example2</a></li>
<li><a href="/example3/">Example3</a></li>
<li><a href="/example4/">Example4</a></li>
<li><a href="/example5/">Example5</a></li>
</ul>
</div>
<div class="dbx-box">
<h3 class="dbx-handle" title="Example6">Example6</h3>
<ul class="dbx-content">
<li><a href="/example7/">Example7</a></li>
<li><a href="/example8/">Example8</a></li>
</ul>
</div>
</div>
</div
</body>
</html>
And it works as it suppose to... Nothing wrong on it.
-
Where is the PHP code? Or is that the page your trying to include?
-
Oh sorry..
Here;
PHP Code:
</div>
<div id="secondaryContent">
<?php
if (isLoggedIn() == true)
//Here goes the include code im looking for
?>
</div>
</div>
</div>
</div>
<div id="footer">
<ul>
<br>
© 2008
</ul>
</div>
</body>
</html>
-
Bearded (M|G)od
You should have no problem with:
PHP Code:
<?php if (isLoggedIn() == true) include 'sidebar.html'; ?>
Are you sure your isLoggedIn() function is returning true?
-
It worked with a more simpler sidebar... but not with this one, no its just returning blank, no errors, nothing...
-
So there could be an issue with the sidebar code then. The PHP seems to be fine.
-
Bearded (M|G)od
I have a feeling that it has to do with your <?xml declaration. <? is an entry PHP tag, so it may be trying to parse the whole page as a block of PHP code.
For your sidebar.html page, you shouldn't even be having the whole page declaration and whatnot because the code will already exist on the page.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|