Log in

View Full Version : External embedding



Austin Klei
03-07-2010, 07:22 PM
Alright, i need help on this...


I have several websites that i run, i made a network bar for them and i made it with this code:



<style type="text/css">
#networkbarbody {
float: left;
top:0px;
left:0px;
position: fixed;
width:1600px;
height:20px;
margin:0 0 0px 0px;
background:url("http://media.ignimgs.com/media/ign/corp-networkbar-bg.gif") center;
background-repeat: repeat-x;
overflow:show;
}

#networkbartext {
float: left;
font-size: 12px;
color: #FFFFFFF;
}

.networklinks A:link {
color: lightgreen;
text-decoration: none;
}

.networklinks A:visited {
color: darkred;
text-decoration: none;
}

.networklinks A:active {
color: purple;
text-decoration: none;
}

.networklinks A:hover {
color: gold;
text-decoration: underline;
}
</style>
<script>

var browserType;

if (document.layers) {browserType = "nn4"}
if (document.all) {browserType = "ie"}
if (window.navigator.userAgent.toLowerCase().match("gecko")) {
browserType= "gecko"
}

function hide() {
if (browserType == "gecko" )
document.poppedLayer =
eval('document.getElementById("networkbarbody")');
else if (browserType == "ie")
document.poppedLayer =
eval('document.getElementById("networkbarbody")');
else
document.poppedLayer =
eval('document.layers["realtooltip"]');
document.poppedLayer.style.visibility = "hidden";
}

function show() {
if (browserType == "gecko" )
document.poppedLayer =
eval('document.getElementById("networkbarbody")');
else if (browserType == "ie")
document.poppedLayer =
eval('document.getElementById("networkbarbody")');
else
document.poppedLayer =
eval('document.layers["realtooltip"]');
document.poppedLayer.style.visibility = "visible";
}

</script><div id="networkbarbody"><div id="networkbartext"><span class="networklinks">SWBFII Networks: <a href="http://www.lucasarts.com/">Lucasarts</a> | <a href="http://www.swbfnetworks.realbb.net/">SWBFNetworks</a> | <a href="http://www.swbfii.com">SWBFII.COM</a></span> <input type=button onClick="hide()" value="Close the Network Bar!">

</div></div><div align="Center"><input type=button onClick="show()" value="Reopen the Network bar!"></div>


I really want to be able to change the content of it, all at once, at the same time. Because if the network gets large, i cannot update it seperatly. So is there a way i can embed it, and update it by just using one or 2 files. I am planning to add other sites that i dont run, and i dont want them to be able to change it without having the files. I just want to change it all, from one place. And i will do all it takes to do it.

djr33
03-07-2010, 07:28 PM
i dont want them to be able to change it without having the files. I just want to change it all, from one place.If they remove the embedding code, they can block it. But beyond that, you can have one line of embedding that will then bring in the content from your website.

Here's how it works. You need to use a server side language like PHP, ASP, CGI, etc.
You could try to use Javascript and frames or something, but that would get messy.

Including an element in every page is very easy in PHP (as an example):
<?php include('bar.htm'); ?>

That line will take all of the content from bar.htm and embed it directly into the source code as if it were typed directly into the other page's source. It's clean, processes on the server, and the only complication is making sure that once added together it functions. For example, you don't want to embed an extra layer of <html>...</html>, so only include that in the main pages.


The problem with this for you is that you need that file to be hosted on a different server. This is still possible but can cause some issues.

<?php include('http://example.com/bar.htm'); ?>

That should work. HOWEVER, be aware that PHP has possible restrictions against remote URLs. Basically you need to be sure that each server you use this on allows remote urls in PHP. It may vary by server and since you plan to use a lot of servers this is a concern. It should work, though, if that is not a problem.
(Note that this has absolutely nothing to do with the website you're creating bar.htm on-- that can be any setup at all because the other ones will just effectively "visit" your page.)




If this is too complex you can always use a frame/iframe, but that will be messy and sometimes have conflicts with other things going on at their websites.

Austin Klei
03-07-2010, 07:53 PM
Yes, i understand that. But im only bringing in one part of it. Which my network bar before i started to ask questions is: http://swbfiitemple.forumotion.com/portal.htm


As you can see, i have it placed in an HTML page

I want it to do the same thing it does right now. I'm not worried about them downloading the codes... I just want to edit it all from one place, where all of the websites get the content from one place.


In short, i just want to be able to have that, and with lots of websites with it, where i can edit it on one place, and it will update it all. Kind of like editing a .js file, you tell it what to do.

djr33
03-07-2010, 11:11 PM
That's exactly what the method above will do.
When you create the page to be embedded, create ONLY the code for the menu itself and NOT a full page. Then embed that directly into each page using PHP or another similar language and you will be fine.

So to repeat: menu.htm (or whatever you call it) ONLY has the code for the menu itself, such as: <div>.....menu here.....</div>

Austin Klei
03-08-2010, 12:25 AM
I Wouldn't be good at this, could you give me the codes?

djr33
03-08-2010, 10:19 AM
Read the post above. The code is just one line, an include in PHP.
Then make the ELEMENT of the html that you want, NOT a full page. Include that file into any page using the code.

Your page "menu.htm": <div>My Menu</div>
Their page(s): <?php include('http://example.com/menu.htm'); ?>

And just put that part wherever on their page you'd like it to show up....

Austin Klei
03-08-2010, 08:35 PM
I understand that, but i cannot put php on a page with .htm or .html

molendijk
03-08-2010, 09:28 PM
Then you could consider using (a sophisticated version of) iframes/objects, see this (http://www.let.rug.nl/molendyk/include_menu14_even_anylink/menu.html).
===
Arie Molendijk.

djr33
03-09-2010, 02:32 AM
While it is possible to do that, it is a much cleaner approach if you can use server side code to do it. There are ways around "not being able to use php in .htm" etc., but in some way you will have to make all of the websites work with PHP.

It will be easier to use the method in the post above, though not better and perhaps worse depending on a few details, mainly that then the final page is at least two parts, rather than just one and may not be supported by all browsers/systems, though likely most.