I have my web page setup to use a new management system, but would also like to use some basic html pages for other content (such as images or whatever), and I seem to remember from years ago that there was a way to use PHP to load HTML pages that are not formatted into a content area, which I assume are DIVs.
I also seem to remember that I didn't have to create an if statement, but I'm not sure and quite honestly I'm awfully confused about how to do this. A friend used to do this coding for me way back when, so the way it was setup was that all I had to do was tell my navigation where to find the file and it would load it inside of my index.php file.
Hopefully my question is clear, but if not, my website is right here, and I just want my HTML files to load into the are with the content image, but only the grey portion (which I do have a DIV set up for). Any help would be much appreciated! Thanks!
The simplest way is by using require and include.
for more details, you can visit the following link:
http://www.w3schools.com/php/php_includes.asp
For example:
<?php include 'footer.html';?>
Related
I built my website in 2007 using html and css which I learnt from a book. I'm a jeweller and it's used as a portfolio of my work and therefore has lots of photos on it and separate pages with each photo. I have continued to add photos and pages and not made much changes to the overall structure of the website, just copied and pasted the code into each new page and changed the bits I needed to.
But now I want to change the headers and footers of all these pages, and there's hundreds of pages!
After some reading it seems I can use PHP (just finding out about this) to insert headers and footers. Which seems to mean I'd need to edit every page of code anyway, and change all links in the code to .php, which would be the same (or more!) amount of work as just changing the code on every page to be what I want, although will make it easier next time I want to change.... so wondered if there was another way of doing this?
First time asking anything on a web developer forum! As I'm sure you can tell I'm no expert so keep things simple please! My website is www.islayspalding.co.uk. Many thanks :)
I am doing some freelance work for a client and I need to re-code an old menu. The entire site is static which will make this process extremely slow and redundant, does anyone have a good technique for updating multiple pages automatically?
The old developer used "Allwebmenus" which is a automatic menu creation tool. It is implemented by using JavaScript which writes HTML to the DOM. I'm going to replace this with a clean html menu and some simple jQuery.
Right now I think the best way is to create a separate .html file with the menu code, and use PHP includes on all the pages but this still requires me to update every page on the site. Can anyone give me better idea? Or do you think this is the best option?
Thanks for the help!
create menu.php and include("menu.php") into each file where the old menu's are written.
It will make your life easier going forward too.
As far as fixing all the static pages, you will have to go in and do that yourself.
include("menu.html");
You can use includes, but it might also make since to put them onto a CMS like Drupal. Handles a lot of that for you.
Using the PHP includes is a good method. If the "Allwebmenus" has Javascript code on each page, you'll have to edit each file anyways, so adding the includes is no big deal.
Until now, I've been using the <iframe> tag to load things like headers/footers/navbars into my webpage. These cause so much hassle though and as I'm about to start building a new site I thought I'd get it sorted now.
I was thinking of having all the html code in a php file and just loading it in dynamically.. Ideally I'd like the code to become a part of the page. So it appears inline. But I also want to be able to edit one single file if I need to change one bit rather than editing the same file 100 times.
<iframe>'s did this well until recently and I don't want to use workarounds to solve my problems. Could someone please post some code I could adapt or post a link to something that tells me how to do this? Cheers
You can use PHP's include() function to include elements like headers and footers in your pages.
So:
include('header.php');
. . . will look for a file called header.php in the same directory and include it in your page. Then you just need to write this at the top of your pages.
That said, this isn't really a very good way to go about designing your site. How about looking for a content management system, that allows you to keep the design and content of your site separate?
Are PHP includes what you're looking for ? http://php.net/manual/en/function.include.php
Learning how to code by editing an existing dynamic pages site that is live.
Have a question on how to edit dynamic pages.
For ex: I want to edit static text on a page. I can figure out stuff using firebug and seeing html, nodes, etc but I have no idea how to find the correct/relevant file on my server to edit and make changes the static text so something else. I see CSS files, js files. Is it a php file maybe? Where should I look? Maybe other files? Can't seem to figure out! Thanks for your help!
If the text comes out of a database/CMS, you'll have to search the database.
If the text is hard-coded in the code itself, use a search utility on that set of folders to find a match.
You can't always tell looking at the output on the client to determine the source unless you're familiar with the code.
A friend has asked me for help with her website design. Although I know a fair amount about the basics behind HTML, XML, Php, ASP.Net, javascript, etc., I'm not really comfortable sitting down and coding from scratch. All of the work I do is in Java, C++, and so on.
My friend would like to add a vertically scrolling marquee to her site - no problem, there is code for that all over the internet. Here is the tricky part - she would like the text to be dynamically pulled from another website. This isn't like a simple text file, either - it's a list of names from a specific blog post, so there would be a lot of text processing involved to wade through all of the other markup, and extract the relevant info.
The way I see it, here are her options -
1) Write some kind of a perl script or somesuch that is set to run daily. This script will visit the blog and extract the necessary info. It will then update the HTML file's marquee text with its new info.
2) Some sort of active page written in ASP or PHP that will dynamically build the marquee (and the rest of the site) each time the site is visited, basically doing the work of the perl script each time. This seems like it has the potential to be somewhat slow.
Per my understanding, those are her only options. Am I correct? There is no simply way to do this in javascript that I am just missing? I know you can reference an image to be dynamically pulled with the marquee, but this isn't that simple...
Thanks.
EDIT: I guess where I was going with my question was this: Unless I implement this statically, this is going to be fairly involved, right? I believe it is over my head. This is why I would like to simply copy/paste the text list into the html document. It would need to be updated every time the blog does, but that only appears to happen every few months, so that's not a large chore. I realize this is a lazy solution, but this is from someone very inexperienced in web development.
For reference, this is the SPECIFIC blog post which the text will come from, and my friend would ONLY like to display that list of names that begins when you scroll several paragraphs down.
http://truthnottasers.blogspot.com/2008/04/what-follows-are-names-where-known.html
It depends what the list of names looks like, i.e. how much intelligence is needed to parse it. But this could be something that could be fairly easily be pulled, parsed and displayed using Ajax, for example in the jquery flavour.
All the blogs I have ever seen have an RSS feed. Why not just grab the feed?... Google provides javascript that does only this.
Google Ajax Feed API
The RSS suggestion sounds good. If you can't get it in the RSS you could screen scrape the content.
If you could do it with Javascript I think it would suffer the same resource issues as your once a day Perl script and every load asp/php methods since it would still have to fetch the web content by making a call to the web site.
Another option is to use asp.net and enable caching so that when other visitors come to the site instead of getting the page all over again it serves up the cached page. You can set this to cache for 24 hours or so. I'm sure other server languages have similar features. Basically this would be the same as your once a day Perl method but keep it within a web framework.
Another hacky solution would be to use an iframe and frame the content with javascript so that it only shows the content you want to show. Of course you'll have no control over the formatting (background, fonts) of the iframe and if the content gets bigger or changes position you'll have problems.