Log in

View Full Version : Resolved Xml



robin9000
02-02-2009, 12:39 AM
Is there any way to take the menu I found on here and place it in an external file like XML and then refer to it.

I don't know XML but was thinking it might be the way to do this. Maybe there really is no solution to this, I don't know but let me explaine why I want to.
I want to do this so that I can update any menu items on one page and have it translate through out all my pages with out having to place the code into a frame.

<div id="myslidemenu" class="jqueryslidemenu">
<ul>
<li><a href="http://www.dynamicdrive.com">Item 1</a></li>
<li><a href="#">Item 2</a></li>
<li><a href="#">Folder 1</a>
<ul>
<li><a href="#">Sub Item 1.1</a></li>
<li><a href="#">Sub Item 1.2</a></li>
<li><a href="#">Sub Item 1.3</a></li>
<li><a href="#">Sub Item 1.4</a></li>
</ul>
</li>
<li><a href="#">Item 3</a></li>
<li><a href="#">Folder 2</a>
<ul>
<li><a href="#">Sub Item 2.1</a></li>
<li><a href="#">Folder 2.1</a>
<ul>
<li><a href="#">Sub Item 2.1.1</a></li>
<li><a href="#">Sub Item 2.1.2</a></li>
<li><a href="#">Folder 3.1.1</a>
<ul>
<li><a href="#">Sub Item 3.1.1.1</a></li>
<li><a href="#">Sub Item 3.1.1.2</a></li>
<li><a href="#">Sub Item 3.1.1.3</a></li>
<li><a href="#">Sub Item 3.1.1.4</a></li>
<li><a href="#">Sub Item 3.1.1.5</a></li>
</ul>
</li>
<li><a href="#">Sub Item 2.1.4</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="http://www.dynamicdrive.com/style/">Item 4</a></li>
</ul>
<br style="clear: left" />
</div>


Thanks all

bluewalrus
02-02-2009, 04:35 AM
Should be able to do it with php if your server has it. http://www.w3schools.com/PHP/php_includes.asp

robin9000
02-02-2009, 12:49 PM
I know the hoster I am dealing with has support for PHP but after looking at the example and going through some of the pages, I am kinda confused as how to use it. Do I need to learn a hole new programing language to use it?

The example I got from what you showed me is:
<html>
<body>

<?php
include("wrongFile.php");
echo "Hello World!";
?>

</body>
</html>

But I don't exactly understand how this is going to help. I cleary understand that you creat a PHP document and that the coding above is used to then refure to the PHP document. I get that part. But what I don't quite understand is do I have to code everything in PHP to create a document?

I have tried to do it just as a server side include as follows:
<!--#include virtual="menu.html" --> but it did not work, any reason why not?,
It shows up like as if it's woking in my Dreamweaver but not in the browser.

Twey
02-02-2009, 03:31 PM
Yes, PHP is an entirely new language. It's very powerful. You do technically have to code everything in PHP to create a document, but PHP allows you to escape from the PHP parsing mode (in fact it is escaped by default) so you can write plain HTML and PHP will just print it normally.

No, XML is not the way to go. You can do it in plain HTML with an include, as seen here, or with Javascript and DOM manipulation.

robin9000
02-02-2009, 03:48 PM
Would it be posible to give me a small example of how the opening and closing tags would work inside the PHP document as so I can use html inside a php file?

Thank you.

Twey
02-02-2009, 06:38 PM
Anything wrapped in <?php ... ?> (or, obsoletely, <? ... ?>, <?= ?>, or <script language="php"> ... </script>) is PHP code. Anything else will be treated as plain text or HTML and output verbatim (although PHP blocks and output buffers may be used to modify this).