[Pro] iframes and bookmarks

I’m working on a website that will allow visitors to view hundreds of different items. It’s easy to create an iframe, then have thumbnails load each item into the frame. Problem is I want each item/page to be bookmarkable, and with an iframe, the page url never changes. The solution so far has been to duplicate the parent page, each with distinct iframe content. Works great, but generates a huge number of pages. Is there a way to code the the thumbnail links to reload the parent page with new content and a distinct url so that the page can be bookmarked? Hope that’s clear. Any help would be appreciated.

Thanks, David


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

Is the content in these iFrames from external sites - or from your own site.

David


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

This is one of the major flaws with frames of any kind. If you have PHP on your server, you can work around this by having a single outer frame page, then passing the desired in-frame page to it with a query string:

http://example.com/frame.php?page=foo

If you’ve gone that far, then you could also drop the iframe entirely and use a template page in PHP and pull in the desired fragment. For a site with this many structured pages, that’s what I would do anyway.

Walter


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

Walter,

Thanks for the reply… I guessed it was heading that direction. Knowing nothing of php, I assume “frame” is the name of my iframe, and “page” is the content via a relative path. Is that right?

Thanks again, David


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

Not quite. frame.php is the one iframe page that you construct in
Freeway, and page is a variable that you pass to that page in the URL
to explain which HTML page to load into the iframe.

What you would do is add a block of code like this to the top of your
iframe page, using the Page / HTML Markup dialog, in the Before HTML
section:

and then you would enter this in your iframe Action in place of the
URL of the page you wanted to load:

<?php echo $page; ?>

And you would also make sure to give your frame page the filename
‘frame.php’. Taken together, these changes allow you to pass a GET
variable (the ?page=whatever part of the URL) to the iframe page, and
the iframe will load that requested page.

Since you are giving bad people the keys to your server when you do
this, the script above includes a bit of rudimentary security. The
extension .html is tacked on to the end of whatever is passed in for
the page variable. So anyone who tried passing in .page=.htpasswd to
get a copy of your hashed passwords would instead try to
load .htpasswd.html, which doesn’t exist, and get an error for their
trouble.

What this means in practice is that you would need to put all of your
frame pages in one folder alongside the iframe page, and you would
construct the link to load such a composite page like this (to load
widgets.html into the frame):

frame.php?page=widgets

You would construct this link using the External tab in the Hyperlink
dialog. If you follow these steps, you will be able to create
bookmarkable links to iframe pages. The querystring (the part of the
URL after the ?) will be saved along with the rest of the URL in the
bookmark. As long as the sub-page exists, it will load into the one
and only iframe as if it was the default. No need to create a separate
iframe for each.

Now, for extra credit, if you want to replace the iframe altogether,
and get around the issues of a page-within-a-page and extra scroll
bars, you can take this very easily to the next level.

Apply the PHP Make Insert Page Action to each of your “inset” pages.
This will strip off the HEAD and BODY tags, and leave only the inner
portion of the page code behind. If you have any rollovers or other
fancy stuff in these pages, be sure to check the option for “Preserve
HEAD Content”.

Now back in your frame.php page, get rid of the iframe altogether. In
its place, create a stand-alone Markup Item. (Make sure nothing on the
page is selected, then from the main menu choose Insert / Markup
Item.) In the code dialog for the markup item, enter this line of code:

<?php include(dirname(__FILE__) . '/' . $page); ?>

Now, instead of using an iframe, your frame page will load the actual
HTML from the inset page into itself. This means that if you have
constructed the rest of your page carefully, everything else in the
page will “flex” around the inserted content and it will appear to be
(because it actually is, once it leaves the server and is sent to the
browser) a single page.

Walter

On Aug 22, 2011, at 10:42 PM, David wrote:

Walter,

Thanks for the reply… I guessed it was heading that direction.
Knowing nothing of php, I assume “frame” is the name of my iframe,
and “page” is the content via a relative path. Is that right?

Thanks again, David


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,

Thanks again. It seems to me that option one here is better suited to my page design. I think I understand everything but the most fundamental aspect-creating the frame.php page in Freeway. Is that just the html page I have already created with the php code inserted in the before HTML section? If so, I’ll get started on the site revision. I’m assuming I can only test this after uploading the server. (?)

Many thanks for your help-David


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

BTW, the site I’m reworking is http://www.christiancaine.com


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

You’re right on both counts.

Walter


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

Walter,

Everything is working jus the way I need it to. Thanks again. One final question… is there a way that frame content can be shared by two different iframe pages in two different folders when the links are on the content pages? I can supply relative path links on both sides of the “?”, but that ties me to only one of the two iframe pages. A relative path link only on the right side of the “?” causes the browser to look in the content folder for the frame.php page. (Folder A has an iframe page, folder B has an iframe page, and folder C contains content for both pages, and the navigation is on the content pages. Think a gallery shared by two pages.) Any thoughts?

Thanks, David


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

The easiest way to do this would be to make the change in the PHP.

content
	page1.html
	page2.html
	...
folder_a
	frame.php
folder_b
	frame.php

On all of your content pages, the URLs should be in this form:

frame.php?page=page1
frame.php?page=page2

This causes the link to go into the current folder.

Then, inside the PHP at the top of your page, your last line changes
to this:

$page = '../content/' . trim(strip_tags($_GET['page'])) . '.html';

The include() statement later on in the page will take care of the
rest. Regardless of which folder the frame.php file is in, the
requested file will be taken from the one and only content folder.

Walter

On Aug 24, 2011, at 9:15 PM, David wrote:

Walter,

Everything is working jus the way I need it to. Thanks again. One
final question… is there a way that frame content can be shared by
two different iframe pages in two different folders when the links
are on the content pages? I can supply relative path links on both
sides of the “?”, but that ties me to only one of the two iframe
pages. A relative path link only on the right side of the “?”
causes the browser to look in the content folder for the frame.php
page. (Folder A has an iframe page, folder B has an iframe page,
and folder C contains content for both pages, and the navigation is
on the content pages. Think a gallery shared by two pages.) Any
thoughts?

Thanks, David


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

Both iframe pages have the same name.


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

But they are in different folders. That’s why it’s okay. The path has
to be unique, not every segment in it. If you deep-link to one frame
or the other, you would do so (from another page) as

folder_a/frame.php?page=page3

But once you’re looking at the links on page3.html, you want those to
work independent of which folder called them, so if you had a link on
page3 to page2, you would get folder_a/frame.php?page=page2 if you
followed that link from within folder_a, and the same page would also
appear in folder_b using the exact same link.

Walter

On Aug 24, 2011, at 9:46 PM, David wrote:

Both iframe pages have the same name.


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

Sorry, when I wrote that about the file names, I didn’t see you had replied… that was just more info. Thanks for the help again. I’ll give that a shot. The size of the website has shrunk tremendously already!


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

I change the code in the frame.php file to direct it to the content folder, and reset the content page links as they should be, but as before, it’s looking for the frame.php file in the content folder. I don’t have an include() statement in the php file, so that my be the issue.


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

Sorry, no, I wrote include when I meant echo. Did you add the …/
content/ part in the PHP where the $page variable gets built? If you
do that, the iframe would look “up and over” to the content folder,
not inside the current folder.

Walter

On Aug 24, 2011, at 10:58 PM, David wrote:

I change the code in the frame.php file to direct it to the content
folder, and reset the content page links as they should be, but as
before, it’s looking for the frame.php file in the content folder.
I don’t have an include() statement in the php file, so that my be
the issue.


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,
Good morning. In the PHP page I have

<?php $page = '../portcontent/portring0101.html'; if (isset($_GET['page'])){ $page = '../portcontent/' . trim(strip_tags($_GET['page'])) . '.html'; } ?>

and, in the iframe URL on that page,

<?php echo $page; ?>

In the content page, in another folder, the links are

portfolio.php?page=portring0101

Does that all look right?

Thanks, David


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

That looks right. One thing to try, add the Target = _top attribute to
those links. I forgot about the iframe stealing scope. If you were
doing the PHP include, what I wrote would work correctly. But since
you’re in an iframe, the default target is _self, and the link will
look for portfolio.php in the portcontent folder, as you’ve seen.

Walter

On Aug 25, 2011, at 9:31 AM, David wrote:

Walter,
Good morning. In the PHP page I have

<?php $page = '../portcontent/portring0101.html'; if (isset($_GET['page'])){ $page = '../portcontent/' . trim(strip_tags($_GET['page'])) . '.html'; } ?>

and, in the iframe URL on that page,

<?php echo $page; ?>

In the content page, in another folder, the links are

portfolio.php?page=portring0101

Does that all look right?

Thanks, David


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 had selected the _top option from the URL dialog box before, but I added target=_top to the actual link in the external dialog box, and I’m still getting this:
The requested URL /2011/portcontent/portfolio.php was not found on this server.
It’s still looking in the wrong place. If I specify the location of portfolio.php, it works fine but obviously for only one of the two “portfolio” files. It seems to be the portfolio.php part of the link on the content page that’s causing the problem. Can that be replaced with a variable like _parent?
I may have to go the other route with these two sections.


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

I just started sketching this out in Freeway so I could see the
problem first-hand. The issue is that there’s nothing in the iframe to
tell the inner page what outer page holds it. This doesn’t seem
solvable in the iframe idiom without using something fragile like
JavaScript.

So try this. In your Document Setup dialog, make sure that External
Stylesheets is turned ON. On each of your current “content” pages,
apply the PHP Make Insert Page Action (available at ActionsForge). On
each of your frame.php pages, remove the iframe Action and replace it
with a same-size Markup Item containing this line of code:

<?php include($page); ?>

(To get a sized, positioned Markup Item on your page, click on a blank
part of the page, so nothing is selected) then choose Insert / Markup
Item from the main menu. A dialog will appear, where you will type or
paste the code above, and when you Okay that, you will see a 100px
square element in the middle of the screen. Drag and resize this
element until it is where you want your content to appear.)

Once you have done this, the code as written should work. You will
need to modify one other line in the original PHP block – I forgot
you have the default value of $page in the 4th line – so be sure that
you have the …/pages/ part in there as well.

Walter

On Aug 25, 2011, at 10:44 AM, David wrote:

I had selected the _top option from the URL dialog box before, but I
added target=_top to the actual link in the external dialog box, and
I’m still getting this:
The requested URL /2011/portcontent/portfolio.php was not found on
this server.
It’s still looking in the wrong place. If I specify the location of
portfolio.php, it works fine but obviously for only one of the two
“portfolio” files. It seems to be the portfolio.php part of the
link on the content page that’s causing the problem. Can that be
replaced with a variable like _parent?
I may have to go the other route with these two sections.


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,

Thanks. I guess I should probably just go back and do that on all the pages. I stuck with the iframes because it didn’t sound like I could lock in the size of the markup item, and every page is a set size. I’ll give it a shot.

David


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