Jump to content
xisto Community
tricky77puzzle

How Do I Include A Php Sidebar In My Website? This is a question about PHP...

Recommended Posts

(If I am posting this in the wrong forum, please tell me the correct place to be putting it.)I want to install a global announcement banner on the top my website, in case there is some major update. I am currently learning PHP for this very purpose, and would like to ask how it is made. (I know how the HTML layout is going to look like, I just want to be able to actually include the PHP portion on the website.)I heard it had something to do with includes in PHP... how exactly does this work?

Share this post


Link to post
Share on other sites

all it is is just a section of code being included. THat section of code can be what ever you'd like included and you can place it where ever you likefor exampleindex.php---------------*page start*include('stuff.php');*page end---------------thats how it works. You can apply includes to all individual files you want included or you can make 1 template and include it there, that way the template can be used for all your web pages.

Share this post


Link to post
Share on other sites

all it is is just a section of code being included. THat section of code can be what ever you'd like included and you can place it where ever you like
for example

index.php
---------------
*page start

*include('stuff.php');

*page end
---------------

thats how it works. You can apply includes to all individual files you want included or you can make 1 template and include it there, that way the template can be used for all your web pages.


For some reason, I remember the manual saying that the PHP stuff like that was only for header files.
I'll try that, though, and see if it works.

Share this post


Link to post
Share on other sites

Yes you are right but the thing is that you have to include all files and start sessions and other cookies before you send any header information. However if you like to make different sections and models of code like me then you would include code in method or function and then simply call the function in the part of code where you need it in fact.

Share this post


Link to post
Share on other sites

Yes you are right but the thing is that you have to include all files and start sessions and other cookies before you send any header information. However if you like to make different sections and models of code like me then you would include code in method or function and then simply call the function in the part of code where you need it in fact.

I don't actually need it for functions. I just want to include a sidebar.

Share this post


Link to post
Share on other sites

Design your html page with the sidebars as you want them. Instead of adding the content to the div for the sidebar, do the php include as per above for that div. Make sure the page has a php file extension and not an html extension. (Or mod your htaccess file to have html pages parsed as php.)

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.