lunasmom Posted September 1, 2006 Share Posted September 1, 2006 I'm trying to figure out the best way to handle this, I'm hoping for advice. I have a sidebar that is the same in about 50 pages of html content. I don't want to have to modify 50 files when this sidebar changes, I'd like to somehow insert a link in those html files telling them where to find the updated sidebar. I cannot for the life of me figure out how to look that up. Is it a CSS function? PHP?If someone could point me in the right direction, that would be great. Thanks! Link to comment Share on other sites More sharing options...
Chocolate570 Posted September 1, 2006 Share Posted September 1, 2006 Try using PHP. Save the code to a file called "Sidebar.php"And then in every page that uses the sidebar, put this code where you want the sidebar. <? include("sidebar.php"); ?> Link to comment Share on other sites More sharing options...
lunasmom Posted September 1, 2006 Author Share Posted September 1, 2006 Try using PHP. Save the code to a file called "Sidebar.php"And then in every page that uses the sidebar, put this code where you want the sidebar. <? include("sidebar.php"); ?>My sidebar is currently just HTML and CSS. It looks something like this:<div id="sidebar-a"> <p class="sideHEAD"><u>Head</u></p> <p class="sideHEAD"><a class="side" href="/directory/target.html">Category</a></p> <p class="sideTEXTINDENT"><a class="side" href="/directory/target2.html">Subcategory</a></p></div>If I just add PHP tags to it, like so:<?php<div id="sidebar-a"> <p class="sideHEAD"><u>Head</u></p> <p class="sideHEAD"><a class="side" href="/directory/target.html">Category</a></p> <p class="sideTEXTINDENT"><a class="side" href="/directory/target2.html">Subcategory</a></p></div>?>nothing happens (perhaps rightly so). What piece of this puzzle am I missing? Is there something I need to convert to PHP? Will the include tag read a plain HTML file?Thanks!Melissa Link to comment Share on other sites More sharing options...
Little Goat Posted September 1, 2006 Share Posted September 1, 2006 you don't need to convert it to php, you can include any regular file.if you still want to, here's how: <?phpecho '<div id="sidebar-a"><p class="sideHEAD"><u>Head</u></p><p class="sideHEAD"><a class="side" href="/directory/target.html">Category</a></p><p class="sideTEXTINDENT"><a class="side" href="/directory/target2.html">Subcategory</a></p></div>';?> notice the echo. Link to comment Share on other sites More sharing options...
lunasmom Posted September 2, 2006 Author Share Posted September 2, 2006 you don't need to convert it to php, you can include any regular file.if you still want to, here's how:<?phpecho '<div id="sidebar-a"><p class="sideHEAD"><u>Head</u></p><p class="sideHEAD"><a class="side" href="/directory/target.html">Category</a></p><p class="sideTEXTINDENT"><a class="side" href="/directory/target2.html">Subcategory</a></p></div>';?> notice the echo. Thanks so much for the help!Melissa Link to comment Share on other sites More sharing options...
justsomeguy Posted September 5, 2006 Share Posted September 5, 2006 You don't even need an echo there, you can just have pure HTML/CSS in a PHP file. The PHP engine only gets invoked if it finds <?php ?> tags. But it's good practice to name your files .php if you think that at some point you might want to have PHP in them, because if you do then you won't have to rename everything. Link to comment Share on other sites More sharing options...
Little Goat Posted September 6, 2006 Share Posted September 6, 2006 yes, that is what I said here: you don't need to convert it to php, you can include any regular file. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now