PHP Include Assistance

Hi All,

In the past we have tested a few different PHP Include approaches in Freeway but they all seemed to be a little clunky due to the fact that Freeway places classes and such in the header instead of externalizing them. The following is what we would like to accomplish. If anyone could shed some light on a simple Freeway method it would be appreciated.

PHP INCLUDE NEED
We have some notes with simple styling that we would like to appear on several pages. We would like to do this via a PHP include not an iFrame. Through hand coding this is all pretty simple in approach by making a striped down php page but how could we make our notes page part in freeway a simply include it on other Freeway pages yet keep it’s text styles that have been assigned.

Thank You, Dave


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

Hi Dave
To use an includes correctly you will need to strip out all the items like the head and body tags and just leave the content, because you aren’t supposed to double up on these types of tags within a page.
If you really wanted to create both pages and show one inside the other without using conventional iframes or stripping these pages down then you would need to use something like this:

http://morecss.yellowgreen.de/include-content

This example adds a page within another page and
I would imagine there are other systems based on other frameworks, that can do the same

kind regards max


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

Hi Max,

Thank you for the link. The example appears to be more the hand coded rout and AJAX.

  1. Not really familiar with AJAX, any suggestions as to where we would include the code?

  2. Does AJAX play nicely with the code Freeway and the majority of Actions put out?

  3. Does this method actually place the text on the page like PHP thus enhancing SEO?

Regards, Dave


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

Hi dave this doesn’t place the text on the page, so no its completely invisible to SEO. So if thats important then this would be no use. You will probably have to go down the route of creating proper html files that have just the text you want to show, and strip all the other stuff out.
all the best max


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

Not sure if this will help you, I think it might actually… but an example of the way I use PHP includes with Freeway is as follows (I understand that if you are using PHP scripts that already might know some of what follows):

  1. Create a file called ‘some_info.php’ in BBEdit or similar
  2. Upload it to a folder called say ‘php’ in your main directory
  3. Open the file to ‘Edit’ in an ftp client, this file will then open on your computer
  4. Add the following php code:
<?php $my_text_title = 'This is my title'; $my_text_main = 'Hello, this is my main bit of text, don't forget to escape any quote like /' within the text string as the text string in set between single quotes'; ?>
  1. Add the following piece of code to the ‘Before HTML’ of the Freeway page if it is located in the main home directory, if not then you will need to adjust the path in the include:
<?php include_once('./php/some_info.php'); ?>
  1. On the Freeway page you can simple write <?php echo $my_text_title; ?> somewhere or if the place you are adding the text is too small then add a mark up item and put the code in the window. If you use a mark up item then type a space before it and another after it then select these two spaces along with the mark up item and set a text style to it, if you just type the code in the select the code and set a text style to it. Add <?php echo $my_text_main; ?> to another place on the page.

  2. Change the page to a .php page from freeways default of .html, the page will no longer be wysiwyg.

  3. Upload to the server

  4. Load the page in a browser and it should then show the text you have placed as php variables.

  5. As you have the some_info.php script still open try changing some of the text, save and then reload the page and you will see the text has changed on the web page ‘but you probably already know this!’

I find this to be the easiest and most efective way of using includes with Freeway, I find it so easy to edit and no need to keep uploading the site in Freeway to make many changes that can simply be made by opening a script in Interarchy ‘for example’ or other ftp client and making your changes.
I use some very complicated scripts written in php, database queries, admin sites and I do them all this way.
I also use this method to add styles to some pages, just makes it simple knowing those styles will be there without my worrying if I have them on the Freeway page etc.

The typical start of many of my Freeway site pages might be:

<?php include_once('./my_config_file.php'); // A php script that contains standard presets for every page including file anf directory paths include_once($config['path']['php'] . '/query.content.php'); // Get the script that makes a database query for that page content include_once($config['path']['php'] . '/query.presets_admin.php'); // Get the script that makes a database query for presets on this page ?>

Now with this everything I need to display the content on that page is set in the Before HTML of that page.

HTH

On Oct 20, 2011, at 4:15 PM, TeamSDA wrote:

Hi All,

In the past we have tested a few different PHP Include approaches in Freeway but they all seemed to be a little clunky due to the fact that Freeway places classes and such in the header instead of externalizing them. The following is what we would like to accomplish. If anyone could shed some light on a simple Freeway method it would be appreciated.

PHP INCLUDE NEED
We have some notes with simple styling that we would like to appear on several pages. We would like to do this via a PHP include not an iFrame. Through hand coding this is all pretty simple in approach by making a striped down php page but how could we make our notes page part in freeway a simply include it on other Freeway pages yet keep it’s text styles that have been assigned.

Thank You, Dave


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

Thank you Max, helpful to know. Your AJAX concept may be a simple solution for instances where SEO is not important. Could you describe how to implement it into Freeway?

Mike, So appreciate your info for PHP implementation. We will have a look and give it a go.

Regards, Dave


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

Hi Mike,

Is there a way to have the source page generated from freeway and not have to make it in an external editor. I have seen some actions that appear to strip the freeway pages, perhaps for this purpose. If this is a possibility could you provide a brief description as to how this would be accomplished.

Regards, Dave


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

It’s very simple. Two steps:

First, set your document to use External Stylesheets.

Second, if you are making a page-size fragment, simply apply the PHP Make Insert Page Action to that page (it does not have to be a .php page for this Action to work). All that does is strip off everything except the content of the Body tag, and it renames the #PageDiv tag to avoid ambiguity. The page filename will not be changed, so you make your include to that page.

If you are making a small snippet, then apply the TemplateHelper Action instead – apply that to an HTML box. The box, and all its contents, will be slurped into a file saved alongside the donor page if you check the Make Partial box in the Action interface.

The file will be named thusly: _ThePartialNameYouEnter.ExtensionYouChose. So when it’s time to use that partial, you would create your include request for _myPartial.html if you had entered myPartial in the Name field and chosen HTML as the output format.

Alternatively, you might want to take a look at Tim Plumb’s Simple Include Pro Action suite, available at http://FreewayActions.com

Walter

On Oct 21, 2011, at 1:05 PM, TeamSDA wrote:

Hi Mike,

Is there a way to have the source page generated from freeway and not have to make it in an external editor. I have seen some actions that appear to strip the freeway pages, perhaps for this purpose. If this is a possibility could you provide a brief description as to how this would be accomplished.

Regards, Dave


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 Walt,

Where things get a little unclear is when it comes to styles and also actions like the CSS menu. Since Freeway places a lot of this in the head how do we go about setting things up?

Regards, Dave


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

If you have the latest version of the PHP Make Insert Page Action (from the Forge), then you will see a checkbox labeled “Preserve Head Content” or something like that. Check that, and you should be fine. The only issue will be with any Actions that add setup calls to the onload event. Those can’t be saved. You’ll have to test it out and see how it goes.

Walter

On Oct 21, 2011, at 4:02 PM, TeamSDA wrote:

Hi Walt,

Where things get a little unclear is when it comes to styles and also actions like the CSS menu. Since Freeway places a lot of this in the head how do we go about setting things up?

Regards, Dave


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

Walt,

Sounds promising, we will give it a try. If all goes well this may finally provided a solution for headers and footers when building flexible width page websites.

Thank You, Dave


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

Hi All,

It has been some time since we were on this topic and here I am again coming back to it. Our need has broadened since the first time of this request. In short our need is to be able to set something up on a page that may incorporate actions using javascript styling in the head and so on. We want to be able to repurpose it through a PHP include in other areas of a site.

I believe I am understanding everything walt is explaining except for the slurping of the content into another page. How do we go about bringing either a page size fragment or a snippet into another page?

I have used Tim’s action, super cool, super simple, but it only seems to bring over what is in the html box and anything that gets put outside that box is lost, i.e. javascript, freeway styles and such.

Regards,
Dave


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

PHP Make Insert Page chops off the HTML, HEAD, and BODY tags, and preserves the content of the BODY tag. When you check the Preserve HEAD checkbox, it also saves anything that was in the HEAD (it just puts it alongside the contents of the BODY. Because the opening body tag is removed, any unload event handler that was specified there is completely removed, though. Some of the Softpress Actions rely on that event handler to fire the various JavaScript functions that they write, and this breaks them. That’s why I said that you need to test that.

Now as far as getting the fragments into your page, you have two options. If the page that will be including it is using PHP, then you can use a PHP include or require statement to bring the external page into that page. The syntax is:

<?php include('path/to/fragment.html'); ?>

The fragment page can be PHP or HTML, no difference.

If you need to use JavaScript to include the fragment (say if your outer page is HTML), then you would use the Protaculous Action to do that. Note the ID of the HTML box you want to put the fragment into, then write something like this in the top Function Body editor:

new Ajax.Updater('id_of_the_div', 'path/to/fragment.html', {method: 'get'});

In this case, the fragment must be HTML.

Walter

On Jun 21, 2012, at 11:06 PM, TeamSDA wrote:

Hi All,

It has been some time since we were on this topic and here I am again coming back to it. Our need has broadened since the first time of this request. In short our need is to be able to set something up on a page that may incorporate actions using javascript styling in the head and so on. We want to be able to repurpose it through a PHP include in other areas of a site.

I believe I am understanding everything walt is explaining except for the slurping of the content into another page. How do we go about bringing either a page size fragment or a snippet into another page?

I have used Tim’s action, super cool, super simple, but it only seems to bring over what is in the html box and anything that gets put outside that box is lost, i.e. javascript, freeway styles and such.

Regards,
Dave


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 Walter,

When using the Templet Helper to make the part it come over to the other page just no Java Script functionality. When I try to apply the the Make Insert Page action I get a Java script error.

I must be missing something here as this does not sound to difficult. As for the Actions used in this test, Rollover and target Show Hide Layer.

Regards,
Dave


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

Both Rollover and Target Show/Hide Layer (well, Image, but I think Layer inherits some of its onload issues) require the onload event to preload their hidden elements. There was a version of Rollover that was written for me when I was doing the Softpress.com site (2003 - 2006) that split this between two functions. I needed this because everything in that site was built around “partials” with the outer framework loading nested templates internally. It’s not on the Forge, but I will hunt around here and see if I can find it. You applied one half to the page (to manage the preload) and the other half to the elements on the nested template partial. Outside of that, I don’t know what you’re going to do here, except maybe to switch to a different rollover technique, like Sprites.

Walter

On Jun 22, 2012, at 12:12 AM, TeamSDA wrote:

Hi Walter,

When using the Templet Helper to make the part it come over to the other page just no Java Script functionality. When I try to apply the the Make Insert Page action I get a Java script error.

I must be missing something here as this does not sound to difficult. As for the Actions used in this test, Rollover and target Show Hide Layer.

Regards,
Dave


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 Walter,

We will experiment today. It could be that what we really need here is a special action developed that has two parts. A master container and and a slave container. The slave would look to the master and publish anything that was done in the master i.e. applied actions, styles mark up and such.

If this is possible then it would actually be more what we are in need of as our request is all about a quicker in Freeway work flow and and not web technology i.e. a database.

Regards,
Dave


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