![]() |
|
#11
|
||||
|
||||
Re: Open something in a divYou still need HTML and CSS to build a PHP page. The PHP code you would need is actually very simple. Here's an example:
File 1: layout_top.inc HTML Code:
File 2: layout_bottom.inc HTML Code:
Now to make a page for your site, you would do something like this: HTML Code:
There are only two lines of PHP code in the whole thing, everything else is just HTML and CSS. The big difference is that the code that makes up the layout is in two files, layout_top.inc (which contains the top portion of the layout) and layout_bottom.inc (which contains the bottom portion of the layout). Now instead of putting all the code for your layout in every page, you just include those two files with PHP. All the code that is common two every page can go in those two files. The content that is different (the code in the content div) goes in its own file, which includes the two layout files. __________________
www.blake-foster.com |
||||
|
#12
|
|||
|
|||
Re: Open something in a divI'm sorry but I don't understand, can you give me an example? I want something like frames if you understand me, a fixed banner at top, a left menu, and at right something variable depending on the clicked link from menu frame.
I want just a simple example to do a web site like this ( that is the site that I work for it ) : http://www.coco243.lx.ro/, and when I click the links from the green div, in the red div to appear some informations writed by me, with other words a page displayed in the red div, thanks |
|
#13
|
||||
|
||||
AJAX to the rescue!The task I think you are describing is entirely possible with a little AJAX, which is really just fancy Javascript. Keep in mind, though, that if you structure your site navigation this way, your page content may not be visible to search engines.
Here is a refined example. demo.php (could be demo.html instead) HTML Code:
Notice the two scripts in the head section. You need these so your page has access to the necessary Javascript functions. You also need a tag (preferably a div) with an id attribute. You can change the value of the id attribute as long as you also change the Javascript reference to it. The three links in the list are structured differently only for demonstration purposes. They all operate the same way. Choose one of the three styles and use it consistently. Each link calls the Javascript function get_embedded_html() which comes from the script file get_embedded_html.js. A file path is passed as an argument to each function. In these examples, the paths are simply file names. When you click one of these links, a request is sent to the server. When the server responds, the server's response replaces the contents of the target element. In this example, the target element is <div id="dynamicContent"></div>. get_xml_http_object.js Code:
get_xml_http_object.js is the script that puts the X in AJAX. Don't modify it. It can be reused in any AJAX project. get_embedded_html.js Code:
get_embedded_html.js can be used as a template for creating another set of functions that do a similar task, which is to handle the request to and response from the behind-the-scenes script. I have highlighted the two parts of the script that you might want to customize. The first defines the URL request that is sent to the server. The second defines the ID of the element that the response will be injected into. get_embedded_html.ajax.php PHP Code:
This is the behind-the-scenes script. It is a very simple PHP script that grabs whatever page you ask it to. It acts as a portal to the requested file. You should modify this script to limit the files it has access to. The script does not need to be written in PHP. You could use any other server-side language. However, the path to the script needs to match the path referenced in Javascript. sample_html_page.html HTML Code:
This is a sample HTML page to be embedded. The embedded page should only contain the code that you would find between the body tags of a normal HTML page. sample_php_page.php PHP Code:
This is a sample PHP page to be embedded. All it does is generate HTML. I hope I described this solution well enough. If not, let me know what I need to explain better. |
|
#14
|
||||
|
||||
AJAX to the rescue! (No PHP)The same effect can be achieved without any server-side scripting (PHP). Here are some modifications to the code I posted before.
Change demo.php to demo.html. Replace the list with: HTML Code:
In get_embedded_html.js, change the line: Code:
Code:
Create another sample file: sample_text_page.txt Code:
Now the embedded file will be accessed directly instead of through an intermediate server-side script. |
|
#15
|
||||
|
||||
PHP to the rescue! (No Javascript)There is another option, which is similar to what Blake wrote about. You can use PHP with no Javascript/AJAX. This method should work better with search engines and is compatible with more browsers than the AJAX method.
demo.php PHP Code:
If you are unfamiliar with PHP, this probably looks complicated, but it's really not too bad. You can build up the HTML around the PHP to make the master page look however you want. To add another embedded page to the navigation list, follow the pattern that the other three items in the $pages array use to add another link name and file path. After you click one of the navigation links in your browser, your address bar will look something like this: Code:
If you need a better explanation of what is going on with the PHP, just ask. Last edited by MisterChucker : 25-Mar-2009 at 10:21.
Reason: PHP code formatting
|
Recent GIDBlog
Programming ebook direct download available by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Windows Media Player doesn't open | Snowman | Computer Software Forum - Windows | 3 | 24-Aug-2008 21:34 |
| How to open files outside my program? | DeadOverlord | C++ Forum | 5 | 30-Oct-2007 21:27 |
| Apache default page can't be visited | satimis | Apache Web Server Forum | 0 | 05-Apr-2007 05:40 |
| [ANN] New script engine: Open Basic (Basic syntax) | MKTMK | Computer Programming Advertisements & Offers | 0 | 01-Sep-2005 07:13 |
| [Tutorial] Standard I/O | aaroncohn | C Programming Language | 20 | 27-Feb-2004 22:07 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The