[Pro] including files

I’m designing some PHP pages which will pull in basic html text files from another directory.

Obviously the files I’m including need to be top-and-tail-ed of unnecessary markup, so that html tags etc. aren’t repeated.

Within these html text files, which are shorn of html and head tags, how do I incorporate such things as style instructions without this information actually displaying? Normally it’s in the head of the file, but these files have no :wink:

I DO want styling information in these html snippets, NOT in the main parent PHP file. The reason being that the client will be amending and updating and styling these html snippets. His changes and styles need to be in the snippet.

Hugh


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Hugh,

I would just set-up a separate stylesheet(s) for the snippets and have
the client edit that instead of the include file. He’s still editing
the CSS just that now it’s in a separate file.

Todd


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Todd,

What, have the client edit CSS files?..No Way!

Or do I misunderstand you?

The problem is this client is going to use Dreamweaver to edit html snippets and re-upload them by FTP. They’re pretty web savvy, but I wouldn’t cut them loose with CSS.

ie. they are going to be using a visual web authoring tool to get the page (snippet) looking as they want it, and then they’re going to upload their html page/snippet. I really can’t see them managing CSS classes.

Hugh


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

My thinking was that by separating the styling info used in the
include files from the main CSS you minimize the damage they can do.

Todd

On Aug 7, 2009, at 11:59 AM, hugh wrote:

What, have the client edit CSS files?..No Way!

Or do I misunderstand you?


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yes indeed, that would be so.

But how can DW be set up to only to produce unstyled code?

The main point is that these are, by their essential nature, snippets… so you can’t put any link-rel in them.

Hugh


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

The link to the snippet stylesheet would be included in the head tag
of the parent doc., not the included file.

Here’s a link to my example http://anoptic.com/demo/ssi/index.php

This uses 2 'sheets. One for the primary sheet and one for just the
include.

Todd

On Aug 7, 2009, at 12:17 PM, hugh wrote:

The main point is that these are, by their essential nature,
snippets… so you can’t put any link-rel in them.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

There may very well be a better way to do this as there are some
potential CSS conflicts with this approach that you need to watch out
for.

Something else you can try (instead of using a stylesheet) is wrapping

 tags around everything and styling it that way. For example:
<p>
	<pre style="color: red; font-family: 'Gill Sans';">This text is red  

and uses the Gill Sans font.

This way you keep the styling info with the include file.

Todd


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yes, that’s fine as long as you don’t try and do anything fancy with the includes.

I’d be interested to see your html snippet for that (which I assume you’re including via SSI…!)

But then also, YOU have control of the html snippet you’re producing and using there - I won’t have such control.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This example uses PHP includes but the process is still the same.

Contact me off-list if you want me to send the include file.

Todd

On Aug 7, 2009, at 12:44 PM, hugh wrote:

I’d be interested to see your html snippet for that (which I assume
you’re including via SSI…!)


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

In view of the fact that someone else has control of the content and styling of the ‘snippet’ file, maybe an iFrame would be best?

In some ways I’m loth to use any kind of frames, but it does get around the styling issues I think.

Just need to find an iFrame format that can automatically expand/shrink according to amount of content…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I don’t know anything about frames; never used them. I would be
interested though if you go that route. Let us know.

Todd

On Aug 7, 2009, at 12:58 PM, hugh wrote:

Just need to find an iFrame format that can automatically expand/
shrink according to amount of content…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

There are JavaScript tricks which can do this, but you MUST have the
iframe source and the outer page (which holds the iframe) served from
the same server. If you try to do this with a multi-domain setup, you
won’t be able to access the innerHeight of the iframe, because that
would be a security violation (cross-domain request).

Walter

On Aug 7, 2009, at 1:58 PM, hugh wrote:

Just need to find an iFrame format that can automatically expand/
shrink according to amount of content…


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

No problem there, Walter, it’s all same server.

I think what we’re investigating here are the murky waters between the dry lands of own-design/own-control html authoring…and fully fledged CMS.

The middle ground is always the most awkward…!


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

What about one of the small-step-for-web-kind tools, like MiniCMS or
WebYep?

Walter

On Aug 7, 2009, at 2:51 PM, hugh wrote:

No problem there, Walter, it’s all same server.

I think what we’re investigating here are the murky waters between
the dry lands of own-design/own-control html authoring…and fully
fledged CMS.

The middle ground is always the most awkward…!


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

No, the client needs to be able to do his changes and re-authoring of content in DWeaver. I fully endorse this, CMS is totally the wrong tool/method for them. They are very IT savvy, not at all stupid, and know exactly what they want to do and I fully agree and know the logic of it. Online tinkering about really doesn’t cut it - especially as they don’t have the best broadband connection in the world being out in the sticks a bit (as this country goes!)

It really does make sense for them to write their own html files and upload them,…and have them pulled into a"designed" site by SSI, PHP or iFrame…whatever.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I should add that one of the solutions seriously discussed with the client…is that I give up Freeway and use Dreamweaver.

GULP…!!

(but then, you see, DW has quite sophisticated ‘versioning’ capabilities I believe)


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

If you make them a page in Freeway which they can whip, stir and
liquify in DW, and if they upload it into a separate folder on the
server (not into the main site root), you could write a text-
processing tool in PHP or Perl which would strip off the head and tail
before streaming the resulting fragment to the outer page on request.
It’s a pretty simple trick to find everything inside the body tag:

//php
$full_page = file_get_contents('path/to/their/file.html');
$body = preg_match('/[sS]+?<body[^>]+?>([sS]+?)</body>.+/m',"$1", 

$full_page);
header(‘Content-type: text/html; charset=utf-8’);
print $body;

Then, all you have to do is make sure that they stick to the styles
you defined in the outer page and all will be well.

Walter

On Aug 7, 2009, at 3:02 PM, hugh wrote:

No, the client needs to be able to do his changes and re-authoring
of content in DWeaver. I fully endorse this, CMS is totally the
wrong tool/method for them. They are very IT savvy, not at all
stupid, and know exactly what they want to do and I fully agree and
know the logic of it. Online tinkering about really doesn’t cut it -
especially as they don’t have the best broadband connection in the
world being out in the sticks a bit (as this country goes!)

It really does make sense for them to write their own html files and
upload them,…and have them pulled into a"designed" site by SSI,
PHP or iFrame…whatever.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’d have to get a fuller understanding of how that works, Walter. I’m not quite sure where I put that code you’re showing above (is that the sum of it?)

I tried an AJAX include from Dynamic Drive Dynamic Drive DHTML Scripts- Ajax Includes Script and that worked fine. However, any resources associated with the file being included don’t get displayed (eg. a little PDF icon I use) This is because FW is naturally writing to the Resources folder associated with the file, and the html file code of course refers to ‘Resources/pdficon.gif’…when in fact, once the file is “included” the path to that gif is different.

Using a standard PHP include also pulls the file in nicely, but again without the Resources.

One interesting note is that the PHP method displays all the code and text of the included page in the final output, which is good from a search engine viewpoint I would have thought. The AJAX method doesn’t show the code and text of the included page in the output. It makes the page lighter but less SE friendly?

I’m moving onto iFrames next - maybe that will solve the Resources issue.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

PS.

It has crossed my mind that maybe I should look at this the other way round… that is to say, to pull in the masthead, menu and footer!

So they would just have to ensure that all their files are ended .php and include the correct include code at the right place. Maybe not too onerous!


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

iFrames prove to be the cleanest way of including the file. The iFrame also displays any of included file’s associated graphics, which is a problem with php and ssi (at least it is with a sensible directory structure).

The problem with iFrame is that it doesn’ t display the source of the included page - so there’s a lot of stuff that might be missed by search engines.

Question: do search engines ‘drill down’ from an php-include or SSI page to scan the content of the include source?

If it doesn’t compromise searchability, iFrames are the way to go.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options