#1 2007-12-28 17:55:29
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Includes
G'day.
It would be real handy if I could learn, in a hurry, to do includes. I want to do several posts on a blog, for a sporting event that will occur every day for a week, starting tomorrow. I want to make a mini nav to link all of these posts. I'll put it in a div on each post.
I understand that the include file is a txt file and I simply add an extra link to the file each time I post. Is that correct?
But how do I tell the page to go get the file? Is this a php command? I know nothing of php.
Regards,
Laurie.
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#2 2007-12-28 18:14:26
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
In simple set up if the pages are php
you would place the following where you want the included information to be displayed.
Code: php
<?php include("folder/page.php"); ?>
The included page would be a page without any 'head' or 'body' just have the text/info nothing more. Example if you want to include your navigation inside a side bar div. Create a page with the navigation information and save it as navigation.php;
Code: html
<div id="navigation">
<ul>
<li><a href="index.php">page1.php</a></li>
<li><a href="page2.php">Page 2</a></li>
<li><a href="page3.php">Page 3</a></li>
<li><a href="page4">Page4</a></li>
</ul>
</div>
Then in your pages side bar div place the include
Code: html
<div class="sidebar">
<?php include("folder/navigation.php"); ?>
</div>
The "folder" above would be the folder where you keep your include pages if not in the root.
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#3 2007-12-28 18:14:47
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
So, how does this look, so far?
Code:
div.include_01{
float: left;
width: 120;
background: #336633;
border: 1px solid #ffcc00;
}
div.include_01 h2{
color: #990000
}
<div class="include_01">
(Go get in here) include_01.txt
</div>Thanks,
Laurie.
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#4 2007-12-28 18:21:24
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
<div class="include_01">
(Go get in here) include_01.txt
</div>
???
Are you placing this in the css page or the html of the page?
Your included page needs to have the php extension. include_01.php
(Now remember I am new at the whole of php
)
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#5 2007-12-28 18:23:57
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
Thanks CE.
I saw you were online and hoped you'd respond. We were both typing at the same time.
I'll go to work on it. You might be so kind as to check back on me in a while.
See you must have been away for a few days.
Thanks,
Laurie.
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#6 2007-12-28 18:27:41
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
Are you placing this in the css page or the html of the page?
That was my attempt to work out what goes on the page. Think I can work it out now.
Last edited by laurie_m (2007-12-28 18:28:44)
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#7 2007-12-28 18:28:43
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
Yah, several problems hit me all at once and on top of the holiday.
Computer crashed, I messed up my e-mail program setting it up with the host and had e-mails I couldn't get to. 
Here is a section of my pages I use on my security site.
I have a page saved as mast.php and have this in an 'includes' folder.
Code: html
<ul class="skip">
<li><a href="/accessibility.html">Accessibility</a></li>
<li><a href="#list">Skip to navigation</a></li>
<li><a href="#content">Skip to content</a></li>
<li><a href="/site-map.htm">Sitemap</a></li>
</ul>
<div id="mast">
<object title="photos of eagles in flight" type="application/x-shockwave-flash" data="inside.swf">
<param name="movie" value="inside.swf" />
<noscript><p><img class="liner" alt="photos of eagles in flight" src="inside1.jpg" height="91" width="300" /></p></noscript></object>
<a href="http://www.providerofchoice.net/"><img style="padding-top:5px;" alt="Eagle Systems home alarm systems logo" src="/Logo_120_c.gif" width="350" height="120" /></a>
</div>
Then in the html of all the site pages I have;
Code: html
<div id="container">
<?php include("includes/mast.php"); ?>
<div id="banner">
blah
blah
blah
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#8 2007-12-28 20:40:17
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
Code:
< ?php include("http://www.sapphirecoastnews.com/wp-includes/inc_george_bass.php"); ?>What is in the box above is all that is showing up on the page.
I've simply put that code on the page where I want the mini nav box.
The includes page is:
Code:
<div class="include_01">
<h2>Navy George Bass Surf Boat Marathon 2007/08</h2>
<p><a href="http://www.sapphirecoastnews.com/navy-george-bass-surf-boat-marathon.php">Navy George Bass Surf Boat Marathon Starts Sunday 30 Dec</a></p>
</div>
The css is having no effect on the page where I want it. I've also put it in the top bar to see if that makes any difference and the css works there.
Could the underscores in the file name be the problem?
URL: http://www.sapphirecoastnews.com/navy-g … rathon.php
Regards,
Laurie.
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#9 2007-12-29 00:18:18
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
css code:
Code: css
div.include_01{
float: left;
width: 120px;
background: #ffcc99;
border: 1px solid #ffcc00;
margin: 8px 8px 8px 0;
}
div.include_01 h2{
color: #990000;
text-align: center;
}
php includes file:
Code: php
<div class="include_01">
<h2>Navy George Bass Surf Boat Marathon 2007/08</h2>
<a href="http://www.sapphirecoastnews.com/navy-george-bass-surf-boat-marathon.php">Navy George Bass Surf Boat Marathon Starts Sunday 30 Dec</a>
</div>
html code:
Code: html
<phpcode><?php include("http://www.sapphirecoastnews.com/wp-includes/inc-george-bass.php"); ?></phpcode>
The <phpcode></phpcode> is necessary to make the plugin work.
I've put the css class in the include file.
I've tried about 127 different combinations of these things. Must have some teeny, weeny thing wrong. Good thing I never learned to swear! 
Thanks,
Laurie.
Last edited by laurie_m (2007-12-29 00:20:28)
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#10 2007-12-29 00:49:16
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
Are both pages on the same website?
If not this may be where the problem lies.
If so, try using the folder/page structure and not the full url.
Code: html
<phpcode><?php include("wp-includes/inc-george-bass.php"); ?></phpcode>The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#11 2007-12-29 00:56:03
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
Going on midnight here, need to be back up at 4:30 Should be back on the office pc around ten
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#12 2007-12-29 14:13:26
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
Been looking/working your page, first thing I noticed. In the main content/storycontent beneath the "Australia Travel" banner. It looks as though you placed the include command from the design side and not the code side.
Also you have a slash in front of the page path right in front of the wp-includes. This is telling the browser to go up one level and then look for the folder/page.
Remove the slash in front of the wp-includes since the includes folder is on the same level as the displaying page.
In the topbar you have it coded properly, not sure what is going on here.
I have taken the two pages and have them on my site. I changed nothing more than the includes command I mentioned above. All works fine there. I also played around with it and if I use the full url to the included page, display page goes wacko. I tested it using with and without the 'phpcode' tags. made no difference. Remember this page is not reliant on WP.
Code I used in the topbar
Code: php
<phpcode<?php include("wp-includes/inc-george-bass.php"); ?></phpcode>
Code used in the main content/storycontent
Code: php
<?php include("wp-includes/inc-george-bass.php"); ?>
Main display page - [removed]
Includes page - [removed]
I will download WP and look at things to see if I can find something that may be causing your problem.
Last edited by ColoEagle (2007-12-29 18:34:27)
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#13 2007-12-29 14:32:28
- Steven_A_S
- Member

- From: San Antonio, TX
- Registered: 2006-08-07
- Posts: 443
- I've been thanked 21 times.
-
Re: Includes
There is another way to do includes if you have multiple segments of code you want to include. In the include file, instead of just placing html, you create functions that output the html when they are called. Something like this:
then you do the include like CE showed, but in the beginning, and call the elements where you need them like this:
<?php header(); ?>
and
<?php footer(); ?>
This way, you only need one include file for several elements. Hope I didn't confuse you more. 
Offline
#14 2007-12-29 15:18:03
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
Steven,
With your suggestion, if I follow you correctly.
Rather than have 3 or 4 different include pages I could combine these into a single page.
Use the includes as I do now above the <html>/DTD tags except they will all call the same page.
Then in the page where I want them displayed.
<?php header(); ?>
<?php footer(); ?>
Is my understanding correct?
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#15 2007-12-29 17:21:42
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
Thanks Steven for the trouble you've gone to.
That's great info. I'll keep it in mind for the future. I want to take the php further.
But for now, all I want is to get the thing working. Must have misunderstood something.
CE. You've obviously gone to a lot of work for me. Thanks.
It was the plugin changing the less than symbol to special code. (< to <:; ) and the other ones (> and "...")
When I deactivated the plugin the code all came right.
On the WP forum I've read several posts that say you must have a plugin to use includes in posts and pages, so this must be correct. Dunno why it won't work for me.
So I made things as simple as possible, cutting out all the variables and unknowns:
On my hard drive I've created a new folder called Unpublished php site
I've created a page and called it page.php
Also created a page called new.php
These two files are in the above folder.
This is the display page:
Code: php
<HTML>
<HEAD>
<META NAME="generator" CONTENT="ToniArts EasyHtml v.2.4">
<TITLE>Title of your page</TITLE>
</HEAD>
<BODY>
<?php include("new.php"); ?>
</BODY>
</HTML>
This is the includes file:
Code: php
This should show up on the page!
Should this work or have I misunderstood something?
All I get when I view the display page in browser mode is a blank page. The only possibility I can come up with is that I'm not holding my mouth right.
Or have I altogether misunderstood something about php?
Thanks,
Laurie.
Last edited by laurie_m (2007-12-29 17:27:09)
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#16 2007-12-29 17:36:45
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
Looking at what you have, yes it should work.
Have you tried uploading these two pages to your site and then viewing?
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#17 2007-12-29 18:00:49
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
Thanks CE.
Yes, it works. 
I'll have another go at WP with a simple file. If that doesn't work (and I don't expect it will) I'll review the plugin and if need be, install a different plugin. There are several available.
Thanks,
Laurie.
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#18 2007-12-29 19:25:28
- laurie_m
- Member

- From: Bega, Sapphire Coast Australia
- Registered: 2005-08-18
- Posts: 1377
- I've been thanked 30 times.
-

Re: Includes
Hey! Thanks Fellas!
You can all let out a great cheer. I've got it working. 
There was a problem with the plugin so I installed another one.
Still to fine tune the css. Might need some help with that, later. 
Regards,
Laurie.
John McDouall Stuart - Explorations in Australia
First Expedition Second Expedition Third Expedition Fourth Expedition
Online
#19 2007-12-29 19:30:28
- ColoEagle
- Administrator

- From: Colorado, USA
- Registered: 2006-02-15
- Posts: 2111
- I've been thanked 83 times.
-

Re: Includes
YIPPEE, YAY
Your welcome sir,
CSS - now that I know, 
/* CE
off to
with Stevens include code */
The only way to discover the limits of the possible is to go beyond them into the impossible
Attention designers and webmasters - "The Beauty of CSS"
Valid Web Designs tutorials on HTML, XHTML and CSS
Home Security Systems
Offline
#20 2007-12-31 09:56:31
- Steven_A_S
- Member

- From: San Antonio, TX
- Registered: 2006-08-07
- Posts: 443
- I've been thanked 21 times.
-
Re: Includes
Looks like you pretty much got the gist of it CE. The include doesn't necessarily have to be on top of the page, just before where you'd need to call the first function. I use this method on both of my sites, it gives me one place to go to make changes to all my common code.
Offline
| Never |
- Sponsored Results
|
|