How to place a banner on webpage with one application to all pages of a website - banner

How can I place a banner on webpage with one application to all pages of a website?

One way of doing this is to put your banner into a file, then include that one on each of your other pages. This way, you only have to change the code in one place to update the banner site-wide.
So, a PHP example would be:
banner.inc.php:
<?php
// echo out banner here...
?>
Then, on your other pages:
include("banner.inc.php");

You can just create a header file that you include in all your pages, and include the banner code in it. The solution is pretty much the same in all languages. If your host allows server-side includes, you can even do exact same thing with (nearly) pure HTML. You can also do it with JavaScript pretty easily.

Do you have a global template for all your pages? Something where the basic structure of all your pages is defined while the specific stuff is filled into parts of the body? If you had something like this you could modify the global template to have the banner you want and it would show on all your pages.
Google "html templating" for more.

I recommend using master pages. That way if you have something that has to be changed globally across the project you only have to change it in one place. And they are really simple to use.

If your web server is IIS, and you know a smidge of CSS you can do this without perl, without touching any other files, but at the cost of some performance.
IIS allows you to insert an HTML snippet into anything served:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e27f918e-89a9-45a8-8604-2ad2ded09d64.mspx?mfr=true
If said footer file, had CSS which shoved it to the top, then you would get the behavior you are looking for.
Please note, that this is NOT an ideal solution, but it is a quick and dirty patch until you can go back and retrofit all of your pages with a master page or something similar.

If it really should be on every page of your site, I'd argue that it's part of the site design rather than the content itself. In this case, you are easily justified in setting a background-image in your css. Of course, you probably then still have to have some sort of place-holder element in your html, but at least you could update the whole site together.

Well, hopefully you would have designed the website so that if you need to change something globally, you can just edit a header or footer file.
If not, I would use Perl to go through all the files, and do a search and replace.

Related

One-page AJAX-based WordPress site. How should I do it?

I am trying to create a one-page WordPress website, something like the ones you sometimes see in ThemeForest's WP section: the whole website is a long page that has everything in one place, from about us, to portfolio, to some blog posts, to contacts.
Placing all things on one page is not difficult. But when I started thinking about how to present individual posts and pages, I realised that I probably need a general way of getting posts' data via AJAX, and create new blocks with JS. How should I go about this? I suppose this was done before, but I struggle to find something this specific on Codex or a tutorial with best practices.
Any advice or link will be greatly appreciated.
You could use a plugin such as jQuery Easytabs, download it here, that has a built-in Ajax component.
I've found that the easiest way is to just get all content to load into the divs ahead of time, vs. trying to load all pages through Ajax. However, appending something like '?ajax/ajax' to the end of your urls through the Easytabs plugin is one option that I have successfully used in the past.
If you decide to use the easytabs functionality, there is ample documentation on the page that I linked to.

How to include a html or template file into a .html file?

is it possible, or how could I make it so, I can include my topbar file into my page, I'd prefer it not to be with php since I am not hooked up with localhost yet.
Thanks for all help in advance!
HTML5 now allows you to include html files like you can already include a css file via an import. However, this would only be helpful for during your development stages and not for the final production version since the feature currently is only available in Chrome and will take time for the other browsers to adopt: http://www.html5rocks.com/en/tutorials/webcomponents/imports/
If you don't want to use PHP nor any other server-side scripting language,
you can use either <iframe> or <frameset> tags, which are deprecated, or perform an AJAX request using Javascript that embeds your HTML page dynamically. Second approach will work only if the page you're trying to attach is located within the same domain due to XSS protection in modern browsers.
It's more of a server thing, so to speak, so you would have to rely on the server more for this. Because, you cannot simply do this using static script, like HTML. There's no "built-in function" that can do this, it's not HTML's thing.
I mean, server will offer you more than one option, for example:
You can:
Use SSI (Server-side Includes) if server supports it.
Use PHP or ASP includes.
Otherwise, you can use AJAX for this, won't cost you as much as the above options.
If you mean "header" by saying "topbar", I think it's not a good idea to use iframes.
Files which are truly HTML parsed files can not include another file to my knowledge.
If you web server will parse php you could simply change the extension of the the main file to .php and include() the topbar file:
mv index.html index.php
index.php:
include_once("topbar.html");
Use <!--#include file="footer_text.html" -->
inside html page.
Plz, check below url for details.
https://www.lifewire.com/include-html-file-in-another-3469529

AJAX URLs & URL Rewriting

I am starting to set up a personal website, and I would like it's layout to look something like
-------------------------------
- Page Header & Menus Go Here -
-------------------------------
- Main Contents -
-------------------------------
- Footers -
-------------------------------
The main question is that I would like it to be a single-page interface in which the main contents are loaded and displayed with a combination of AJAX and jQuery to produce a nice effect. However, I would, of course, like to have the contents bookmark-enabled and indexed by search engines. I have skimmed throught the Single Page Interface Manifesto which explains some nice ways of achieving this, but I wouldn't really like to have my URLs like
http://www.mysite.com/index.php#!section=section1
http://www.mysite.com/index.php#!section=section2
I would, of course, like to re-write them as
http://www.mysite.com/section1
http://www.mysite.com/section2
My questions are this whether this approach is correct/doable and if AJAX URLs are compatible with URL rewriting. What URLS would be indexed by, say, Google anyway?
If you want your page to work without reloading and update at the same time the page's URL, the only way to archieve this is by changing the hash in the URL (location.hash = 'whatever').
URL rewriting cannot be used since the hash is not sent to the server, it's only available in the browser's scope.
Check Facebook or Twitter URLs. They are prettier than #!section=section1 but still need the hash.
Cheers.
If you want to load different content/tabs/some content of page without reloading browser,
Now It is possible with pjax..
you can use something like http://padrino-pjax.heroku.com/
you can try it, go to the link and click on any of links home,dinosaurs,aliens
and you will see It will change url and some content without reloading full page
It is achieved using ajax+push/pop of url in browser
I'm looking for a solution myself for a similar problem (I have a client site with an AJAXed wordpress theme, and these dreadful #! stuff on the URL prevent all the Social sharing plugins I have tried so far, from working correctly).
Apparently, there is a solution (with some drawbacks ofc..). I found about it here: http://moz.com/blog/create-crawlable-link-friendly-ajax-websites-using-pushstate
I know it's like two years since you've asked, but it could be helpful for someone else, or you may wanna check it out just for the sake of the curiosity itself! :-)

Changing a web page's skin using AJAX

I've got a cookie set up to store the user's theme preference, etc., but I've never used AJAX before, so I could use a little help.
I found this simple little AJAX tutorial, which is enough to get me started, but I'm not sure if I'd be better off having the server send pretty much the entire web page all over again, with the updated theme, or -- if it is possible -- having the server send a script that would modify the page, keeping the content intact, but changing the div, etc. properties in order to achieve the new look.
Thoughts? Comments? "You're doing it wrong, moron"?
Thanks in advance!
If changing theme means only change the classes of your divs and the elemtes of the structure of your page you must do it simply changing the class="" atribute of the html elemts involved. Ej: You can change postions, and floats, colors etc etc.. This would appen only in client without asking to the server again the page (0% traffic from server, nice!)
But, if changing theme means to get other html structure and hierarchy complety different: You dont have other way that ask to the server the page again with the new html...
Conclusion: Think about all those things, if you can get other theme only changin css you can/must use jquery to change the css properties. But, if not, you need to load the new html from the server...
I hope this help you
pd: sorry for my englisgh grammar if its not correct at all!

Get page content with theme structure in Wordpress

I'm working on an ajax-based Wordpress site and I want to know if there is a way to get a particular page content with theme structure applied in.
One workaround is to use
wget
or
file_get_contents(page_url)
but it'd be cleaner to use Wordpress built-in functions.
Thanks.
I'd go with file_get_contents. I'm not aware of a built-in WP function to do this, but even if there was one I would expect it to be based on file_get_contents
FYI, don't use any of these methods I mentioned above because it's way too slow. I ended up utilizing the Loop and include_once(); to get the content with the theme structure.

Resources