Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
A Dynamic Site in 2 Minutes
Old 08-24-2003, 11:18 AM A Dynamic Site in 2 Minutes
dvduval's Avatar
Ultra Talker

Posts: 312
Trades: 0
For those who want a dynamic site, I'll show you how to do it in PHP, ASP, Cold Fusion or Java. Check with your host to see which of these is available.

The really nice thing about using Header and Footer Include Files is when you change the include files, it changes every page on your site:

For PHP:
Start by changing index.htm to index.php. Then use this code:
<?php
include 'includes/header.php';
?>
add all of your body text, tables, pictures, etc. here (just regular html. cut and paste from your old page if you like)
<?php
include 'includes/footer.php';
?>

Next, create header.php and footer.php and place them in a folder called "includes". In the header file, add your page title and navigational links. In the footer file, add your copyright notice.

To create new pages keep using the above code.
When you want to update links in the header or the copyright date in the footer, all you have to do is change one file, not the whole site.

For ASP:
Same as above but each page with includes should start with:


joined:Sept 28, 2001
posts:349
msg #:3 10:01 pm on Apr 17, 2003 (utc 0)
And in ASP...
<%@ Language=VBScript %>
<% Option Explicit %>

Then use this code for the includes:
<!-- #include virtual="/Includes/header.asp" -->
add your content here
<!-- #include virtual="/Includes/footer.asp" -->

For JSP
Use this code for the includes:
<%@ include file="header.jsp" %>
content goes here
<%@ include file="footer.jsp" %>

For Cold Fusion
Use this code for the includes:
<CFINCLUDE TEMPLATE = "../includes/header.htm">
body here
<CFINCLUDE TEMPLATE = "../includes/footer.htm">

After you get used to doing this you can include files that run programs on the server and then output information. For example, you might want to output random links from your forum, so you create a program that randomly selects from a list of forum posts and then outputs the html to the include. Switching your site to .php extensions (or .jsp or .cfm or .asp) and starting to use headers and footers is the first step into the wonderful world of building dynamic websites!
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dvduval is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-24-2003, 04:34 PM
c2k
c2k's Avatar
Skilled Talker

Posts: 72
Location: Germany
Trades: 0
Hi,
I've got a question concerning dynamic sites.
Personally I use SSI.

But I don't use - since I don't know how else - the way I would like to.
If I've got an index file (page1.shtm), I include the header, the menu, the mainwindow and the footer, the logo and whatever else needs to be included. So this makes the site dynamic.

But the thing I don't like is, that if I would like to change just the menu, I need a new site (page2.shtm if you like to), where I change the include for the menu.

Is there a way so I don't need to create page2.shtm and just change the include reference to the new menu?

Is there another language I can do this?

Thanks for your help.
Mfg,
c2k
c2k is offline
Reply With Quote
View Public Profile
 
Old 09-07-2003, 06:18 PM
nakulgoyal's Avatar
#1Search Engine Optimizer

Posts: 376
Location: Chandigarh, India
Trades: 0
A lot of people can learn from this thread and save a lot of their time and effort.

Thanks dvduval for taking time to post that. People like dvduval make WT a success. Right David ?
__________________
Nakul Goyal
M.Sc (Information Technology), MCP, Brainbench 'MVP', BCIP, CIW Associate

*
Please login or register to view this content. Registration is FREE
*
Please login or register to view this content. Registration is FREE
nakulgoyal is offline
Reply With Quote
View Public Profile Visit nakulgoyal's homepage!
 
Old 09-07-2003, 10:23 PM
dvduval's Avatar
Ultra Talker

Posts: 312
Trades: 0
When I figured out how to do it in PHP, I was really excited because it gave me so much control over my site. Because I had sites on windows servers, I also had to learn in ASP and then Cold Fusion. I've never tried the JSP version, but I assume it works.

If you have never done this, do yourself a favoer: Learn!
I will be the start of a great journey into the power of Server-side Scripting languages.

Thanks for your replies.

Sorry, I don't know about shtml, but hopefully someone else will answer your question.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dvduval is offline
Reply With Quote
View Public Profile
 
Old 09-08-2003, 03:04 PM
c2k
c2k's Avatar
Skilled Talker

Posts: 72
Location: Germany
Trades: 0
Quote:
Sorry, I don't know about shtml, but hopefully someone else will answer your question.
It is the same syntax as i.e. PHP.
I don't know how to change the <include> tag. Therefore I need to create for each site an shtm page.

Do you have to do the same in PHP? Is the <?PHP include...> static or can you change it? Do you need to create a HTML/ PHP file for every site displaying or is it enough just to have index.php and then change the <?include tags>, so you don't have to create a php page for each site being displayed on screen?
c2k is offline
Reply With Quote
View Public Profile
 
Old 09-08-2003, 06:02 PM
dvduval's Avatar
Ultra Talker

Posts: 312
Trades: 0
What do you mean by "site"?
Do you mean a webpage?
Are we only dealing with one domain name here?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
dvduval is offline
Reply With Quote
View Public Profile
 
Old 09-09-2003, 04:35 AM
Skilled Talker

Posts: 52
Location: Leamington, UK
Trades: 0
the include tag in php can dynamicly use verible or arrrays to include pages for example you can store the page names in a array and select them from your address bar ie. index.php?page=contact would include the contact page see the code below

PHP Code:

<?php

// build array of pages

$page["index"]    = "pages/index.php";

$page["home"]    = "pages/home.php";
$page["contact"] = "pages/contact.php";
$page["about"]   = "pages/aboutus.php";

// end array

// load header of the page
include ("header.php");

//check and see if $_GET["page"] is not empty

if (empty($_GET["page"]))
{
        
// load default page
        
include ($page["default"]);
}
elseif (empty(
$page[$_GET["page"]))
{
        
// page isnt in array so display a error
        
echo "no such page found";
}
else
{
        
//load page from url
        
include ($page[$_GET["page"]]);
}

include (
"footer.php");
?>
__________________
Stewart McIntosh -

Last edited by stewis; 09-11-2003 at 11:35 AM..
stewis is offline
Reply With Quote
View Public Profile
 
Old 09-10-2003, 12:39 PM
c2k
c2k's Avatar
Skilled Talker

Posts: 72
Location: Germany
Trades: 0
That's cool.
I think I need to learn some PHP ;D

Thanks!
c2k is offline
Reply With Quote
View Public Profile
 
Old 09-11-2003, 09:50 AM
TimSchroeder's Avatar
Admin/Owner

Posts: 6,141
Location: Orlando, FL
Trades: 0
Pretty Cool David! Thanks
__________________
Webmaster-Talk Admin -
Please login or register to view this content. Registration is FREE
| My
Please login or register to view this content. Registration is FREE
.


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE

TimSchroeder is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to A Dynamic Site in 2 Minutes
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.94062 seconds with 12 queries