[Pro] An 'include' question

Hi all,

I’m doing a site where I have product information displayed under four javascript driven tabs, for efficient space use. the four tabs are Overview, Specs, Testing and Downloads.

I’ve done this before but found it rather awkward in Freeway as I was having to make the html snippets on other pages, publish the other pages, cut out the relevant section, and paste it back into the hard-to-read (my eyes!) markup box. It was all very fiddly, although it works.

This time I thought I might just use in the tab markup, which would save loads of fiddling and copy-paste.

Now…the tabs are a effectively one chunk of code containing four divs, each with its own ID - each ID representing a tab. Thus ID=Overview, ID=Testing etc.

I could make four different pages and give each

a different include to the relevant page. But that means making four pages in Freeway for each product (x 35!)…so could get unwieldy.

Is there a way I can put all the product information, Overview, Specs, Testing and Download on one Freeway page, but somehow mark it up so that only the relevant information is called into the relevant

??

ie. make these product pages a table with four cells, and give each cell an ID. Then the php call from the main page might be <?php include('producta.html?id=test'); ?>…or some such code?

Maybe this should be in dynamo, sorry if it’s out of place. But can anyone suggest whether this might work? And how to get my divs and ID and calls all correct!

cheers
Hugh


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

On Feb 25, 2010, at 10:21 AM, hugh wrote:

But can anyone suggest whether this might work? And how to get my
divs and ID and calls all correct!

Do you have a page online? It might help to see the menu markup.

Todd


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

There’s a couple of different things I would try here. First, yes you
can do what you suggest. Tim Plumb’s Simple Include Pro, or my
TemplateHelper in “partial” mode will each allow you to carve off a
portion of a page and stash it in a separate file, to be re-assembled
later by your server.

But second, I would consider trying to do all this with JavaScript.
Have a look at Paul Dunning’s Tab Action (there’s a tutorial either on
his site or on the Softpress site, not sure which) to make it more
Freeway friendly.

The goal of this second approach is to keep everything in one page,
but simplify the result for the visitor. You can see an example of
this if you visit http://goodserviceguide.com The tabs across the
middle of the page each show results from a different part of the Bay
area, but the entire list is always part of the page HTML. (Nothing is
being assembled from separate pages, it’s all there in the source.)
For this site, I used Control.Tabs from LivePipe.net, but there are
lots of different ways to skin this cat, and it’s even easy to write
long-hand. The only trick is the CSS – getting the height of each
tab’s “page” to drive the overall page height means you’ll need to lay
this out as an inline or “box model” page.

Walter

On Feb 25, 2010, at 11:21 AM, hugh wrote:

Hi all,

I’m doing a site where I have product information displayed under
four javascript driven tabs, for efficient space use. the four tabs
are Overview, Specs, Testing and Downloads.

I’ve done this before but found it rather awkward in Freeway as I
was having to make the html snippets on other pages, publish the
other pages, cut out the relevant section, and paste it back
into the hard-to-read (my eyes!) markup box. It was all very fiddly,
although it works.

This time I thought I might just use in the tab
markup, which would save loads of fiddling and copy-paste.

Now…the tabs are a effectively one chunk of code containing four
divs, each with its own ID - each ID representing a tab. Thus
ID=Overview, ID=Testing etc.

I could make four different pages and give each

a different
include to the relevant page. But that means making four pages in
Freeway for each product (x 35!)…so could get unwieldy.

Is there a way I can put all the product information, Overview,
Specs, Testing and Download on one Freeway page, but somehow mark it
up so that only the relevant information is called into the relevant

??

ie. make these product pages a table with four cells, and give each
cell an ID. Then the php call from the main page might be <?php include('producta.html?id=test'); ?>…or some such code?

Maybe this should be in dynamo, sorry if it’s out of place. But can
anyone suggest whether this might work? And how to get my divs and
ID and calls all correct!

cheers
Hugh


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

Hi Todd,

I’m afraid not…doing all testing on a local MAMP install.

I could skype you the freeway file though? (3.5)

Hugh


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

Hi Walter, thanks for the ideas.

I can’t find Paul Dunning’s ‘Tab Action’…? certainly can’t see it at Actionforge. Is it called something else there?

Not sure whether these will work on 3.5 anyway, but I’ll take a look at the SimpleIncludePro and your TemplateHelper.

Actually, I didn’t really want everything in one page! That’s what I had before and found it unwieldy. I like the idea of the sections being off in their own folder somewhere and being imported in. I may also want to make these folders ‘content management’ friendly, so the client can easily amend product descriptions etc. Seems logical to me to keep them separate.

Hugh


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

Here you go:

http://www.softpress.com/products/greatfeatures/tabs/

I made a quick test to see how quickly and simply I could make a set
of tabs using Freeway and Protaculous, but then Freeway crashed when I
switched back to it one too many times. (I had edited a font set; Bad
Me!)

The generated source is here: http://pastie.org/842859

The relevant JavaScript code is lines 43 - 52, so the answer to my
self-imposed question is 9 lines.

The only trick to this is to set up all your tabs first (I used H2
tags) one after another, and then name all your tab content areas
according to a numerical scheme (I used tab1, tab2, etc.). Everything
is wedged into a single HTML box set to collapse vertically. I don’t
remember if you can do inline HTML boxes in 3.5, I seem to think that
came around in 4.0. You might want to upgrade… I’m just
suggesting… (If you use the Upgrade link on one of the pages in
ActionsForge, like this one: CalendarView - ActionsForge
I’ll get a lovely gift from Softpress…)

Walter

On Feb 25, 2010, at 2:14 PM, hugh wrote:

Hi Walter, thanks for the ideas.

I can’t find Paul Dunning’s ‘Tab Action’…? certainly can’t see it
at Actionforge. Is it called something else there?

Not sure whether these will work on 3.5 anyway, but I’ll take a look
at the SimpleIncludePro and your TemplateHelper.

Actually, I didn’t really want everything in one page! That’s what I
had before and found it unwieldy. I like the idea of the sections
being off in their own folder somewhere and being imported in. I may
also want to make these folders ‘content management’ friendly, so
the client can easily amend product descriptions etc. Seems logical
to me to keep them separate.

Hugh


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

Walter, you don’t need any shiny presents from Softpress, do you?..I mean you already have everyone’s admiration… :wink:

(Nice try, though…!)

I guess what I’m trying to do is similar to this but without the action. I have already succeeded, and have a working site using hand coded tabs, it’s just difficult to manage in (my version) Freeway.

I just want to keep my snippets out of the page (for organisation and CMS purposes) and include them with simple PHP calls.

Only maybe they’re not so simple…


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

Walter, the code you show at Pastie is very like the code I have used before. Now instead of the “bunch of text here” in the tab divs, I want to put a php include call…but a call to only part of an external file.

I thought of using anchors, but they are positions rather than pure sections. So I’m trying to figure out how to make distinct sections out of text (or html) on a separate page.


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

Hugh, download the 30-day trial of Freeway 5, and my Protaculous and
TemplateHelper Actions. I’m sending you a small present.

Walter

On Feb 25, 2010, at 3:10 PM, hugh wrote:

Walter, the code you show at Pastie is very like the code I have
used before. Now instead of the “bunch of text here” in the tab
divs, I want to put a php include call…but a call to only part of
an external file.

I thought of using anchors, but they are positions rather than pure
sections. So I’m trying to figure out how to make distinct sections
out of text (or html) on a separate page.


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

That’s intriguing…! Alright, I will do.


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

Hi Walter,

Just to thank you for the files, I found them very interesting in their own right, good to see actions for tabs in 5!..encourages me to upgrade!!

However, I think we got a little sidetracked from the original point - which was how to include text or html from an external file into these respective tabs (however the tabs are built).

If we look at the code you posted at http://pastie.org/842859 , this is more or less what I’ve already achieved hand-coding tabs using markup items. Now I want to replace the ‘Bits of text here’ with a - again, not too difficult.

However, I want to keep all the content for the four different tabs in ONE single, separate html file. This is the key: one separate file. ie. not on the same Freeway page as my tabs design, but somewhere else altogether. It might not even be Freeway generated code.

But if this separate content was a Freeway generated page, I saw it like this… a single page with single table containing 4 cells, each cell given it’s own ID. The php include call for any given tab would request the relevant ID, and therefore only fill the tab with that particular content.

Make sense?

As I say I don’t know if this is possible. And if it is possible, I’m not sure how to write the IDs and php calls (I do know how to write a basic php include)

Maybe I need to concentrate on your TemplateHelper action ? or Tim’s SimpleInclude one?

Hugh


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

Okay, what you are describing is a text-based database. And yes, it is
possible, but I fear it will become a lot more work than it’s worth.
My own recommendation would be to use separate files, and have the
filename be the key. That’s a natural fit to the problem. But if you
wanted to put everything in one file, here’s a quick blast at how you
might accomplish this.

Use some form of structured text to describe the content. I would
recommend something like Markdown[1], which strays close enough to
English for most clients to manage without tutoring (or counseling).

Then come up with a separator that is not a part of the Markdown
language itself, and use that to delineate the breaks between data.

Finally, write a PHP tool to read and parse the text file, count
markers or search for a particular marker, and display the results up
to the next marker.

So if your file looked like this: http://pastie.org/851661

You could do a quick split of the file into snippets using preg_split()

$data = file_get_contents('/path/to/data.mdown');
$snippets = preg_split('/@@@(.+?)@@@s+/m', $data, -1,  
PREG_SPLIT_DELIM_CAPTURE);

That should get you an array of snippets with the code name from the
delimiter alternating with the contents:

Array
(
     [0] =>
     [1] => snippet123
     [2] => #This is the headline for this snippet

(For some reason, the first element is always empty, I can’t see why,
but that’s Regular Expressions for you. Just get rid of it with
array_shift() or skip empty elements in your loop.)

So you could get a single one by looping through the array and
plucking out the one that matches. Or you could get more creative with
a regular expression and snip out just the one you need from the raw
text, avoiding the overhead of parsing the entire text file into an
array and then looping through it.

Once you have the element, run it though PHP Markdown [2] to turn it
into valid code.

Let me know if you need any more code examples, or if this is enough.

Walter

  1. Daring Fireball: Markdown
  2. http://michelf.com/projects/php-markdown

On Mar 3, 2010, at 7:24 AM, hugh wrote:

However, I want to keep all the content for the four different tabs
in ONE single, separate html file. This is the key: one separate
file. ie. not on the same Freeway page as my tabs design, but
somewhere else altogether. It might not even be Freeway generated
code.

But if this separate content was a Freeway generated page, I saw it
like this… a single page with single table containing 4 cells,
each cell given it’s own ID. The php include call for any given tab
would request the relevant ID, and therefore only fill the tab with
that particular content.


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

Hi Walter,

Yikes…you lost me there, I’m afraid. Another language…more code…more explanations I haven’t the foggiest about! (loops, pregs, arrays…no idea!!)

I think I’ll stick to a simple page per tab, then. I thought it would be easier, it’s obviously not.

cheers
Hugh


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

Just be sure that these “pages” are not complete pages, with a head,
body, etc. They MUST be cut-down snippets – only enough code to
describe the content, nothing more.

That’s what the Simple Include Pro and TemplateHelper Actions will
help you produce. If you look at the example I sent, in the site
folder, open up one of the files that begins with an underscore, like
_snippet_name.html, in a text editor. You’ll see that the only thing
in it will be the contents of whatever DIV it was made from.

If I were doing this with or for a client, I would make a scratch
document to generate these snippets, and only Publish it once. Then
hand off the snippets to the client (tell him or her where they live
on the server, maybe) and let the editing begin.

Walter

On Mar 3, 2010, at 10:24 AM, hugh wrote:

Hi Walter,

Yikes…you lost me there, I’m afraid. Another language…more
code…more explanations I haven’t the foggiest about! (loops, pregs,
arrays…no idea!!)

I think I’ll stick to a simple page per tab, then. I thought it
would be easier, it’s obviously not.

cheers
Hugh


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

Yes, I figured the html would need trimming. I created some content in a Freeway5 page and then tried to apply the TemplateHelper action…I guess I have to create a ‘partial’ per html item, yes?

I’m sorry, I don’t know what a scratch document is.

These ‘snippets’ are not small. If snippet is a page, imagine these pages being 3000-5000 words. They are mostly text, with the occasional table in them (to hold download icons) and the occasional graphic. But they’re not just 100 word snippets!

By the way the TH dialogue options allow insert before or after. Before or after what?

I guess there is no simple way (without actions) to create a Freeway page?.. something to think about!

I love the thought of handing off the snippets to this client…:wink: If you knew the client you’d have a chuckle yourself!

Hugh


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

Answers inline below.

On Mar 3, 2010, at 10:57 AM, hugh wrote:

Yes, I figured the html would need trimming. I created some content
in a Freeway5 page and then tried to apply the TemplateHelper
action…I guess I have to create a ‘partial’ per html item, yes?

I’m sorry, I don’t know what a scratch document is.

I just mean a separate Freeway document that you don’t use for any
other purpose than making these mega-snippets. If you use your main
document, then unless you have manually moved your snippets on the
server to a different folder, each time you upload to make some
unrelated design change, you run the risk of Freeway overwriting the
client’s changes.

These ‘snippets’ are not small. If snippet is a page, imagine these
pages being 3000-5000 words. They are mostly text, with the
occasional table in them (to hold download icons) and the occasional
graphic. But they’re not just 100 word snippets!

By the way the TH dialogue options allow insert before or after.
Before or after what?

Before or after the generated content. Let’s say you had a single DIV
with the words Hello, World in it:

<div id="item32" style="width:500px; height:200px">
<p>Hello World</p>
</div>

Whatever you entered in the before slot would appear before the
opening

tag, and whatever was entered in the after slot would
appear after the closing
.

This is useful when you are programming something, less so when you
are only using the HTML generated by the Action, although you could
put some HTML comments in there to guide the client.

I guess there is no simple way (without actions) to create a Freeway page?.. something to think about!

You could use the PHP Make Insert Page Action, that does take an
entire page, chops off the head and body tags, optionally moves any
styles inside the PageDiv, renames the PageDiv and all child DIVs so
there aren’t any conflicts, etc.

I love the thought of handing off the snippets to this client…:wink:
If you knew the client you’d have a chuckle yourself!

Sounds like you really ought to be looking at sNews or WebYep or
TinyCMS here.

Walter


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

I think I might well take a look at these CMS…because CMS is a requirement of the project anyway. I’ve looked at sNews before, didn’t rate it that much, also used CuteNews which is quite good. Perhaps the best is one of the simplest, SnippetMaster.

The PHP Make Insert action sounds interesting, I will look at that. But the thought that in Freeway you could choose a new page type of (or other variations) might not be as daft as it sounds. It would be a simple way to create a folder full of pure snippets without recourse to actions or the like.

I put this forward for the New Feature prize!.. :wink:


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

Oh, I agree. That would be marvelous, and just the thing for building
fancy Ajax sites that don’t appear to reload.

Walter

On Mar 3, 2010, at 12:23 PM, hugh wrote:

But the thought that in Freeway you could choose a new page type of

(or other variations) might not be as daft as it sounds. It would be a simple way to create a folder full of pure snippets without recourse to actions or the like.

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

and just the thing for building
fancy Ajax sites that don’t appear to reload.

One day Walter I will learn to speak your language…and then we shall smoke a happy pipe together.

:wink:

Hugh


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