Forums / Templates, Stylesheets, Page Layout / iFrame - Forbidden error

iFrame - Forbidden error

Locked
Results 1 to 20 of 20
This thread is locked. New replies are disabled.
05 Apr 2007, 04:04
#1
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

iFrame - Forbidden error

Hi everybody,

I have created a custom page, which contains another zen page in its iframe:

the fragment of the custom page:

<iframe width="100%" scrolling="no" frameborder="0" src="includes/templates/template_default/templates/tpl_page_3_default.php" ></iframe>

The problem is that the iframe cannot open the page and generates a forbidden error: You don't have permission to access /includes/templates/template_default/templates/tpl_page_3_default.php

I cannot figure out what makes this restriction. Please, help

Thanks

Andy
05 Apr 2007, 04:08
#2
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
1

Re: iFrame - Forbidden error

the issue is you are trying to call this outside ZC,

why are you trying to insert zc in an iframe,
05 Apr 2007, 04:51
#3
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: iFrame - Forbidden error

I have fixed the FORBIDDEN error by changing the .htaccess file, but still cannot figure out what is the root page file for zc to call within an iframe.

Obviously, the iframe should contain the includes/application_top.php file

The reason why i need iframe is simple: I have to pass POST (or GET) variables to the truncated zc product page (only the page - no sidebar and the headers). I do not see any other ways how to do this.

What I need is to open the product category page within the iframe, while I assign the product IDs from my custom page containing the iframe.

What is the correct way of doing this?
05 Apr 2007, 04:56
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: iFrame - Forbidden error

Well, Zen Cart isn't designed to operate from within an iframe.

The root file to call for Zen Cart is /index.php

Attempting to access any *.php file under the /includes folder directly from a browser will result in the 403-forbidden error (due to the .htaccess directives).


You've decided that using an iframe is a solution to some particular problem you're trying to solve, or business need you're trying to meet. What is the root need/problem? Perhaps an iframe may not be the "best" solution, and perhaps we can offer some other ideas ...
05 Apr 2007, 05:21
#5
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: iFrame - Forbidden error

The reason why I need the iframe structure is as follows:

1) I need to incorporate a Google API map on my custom page, while the markers are linked to the zc products and categories

2) when the user clicks on the "marker details" on the map, the linked product/category should open below the map

3) I cannot redraw the map - it has to stay untill another set of markers need to be displayed

I would appreciate, if you suggest a better solution than iframes, but so far i could not find anything else to make it work. Right now I have finished the mapping application, it opens on a custom pages with all the coorrect markers linked to products. Next, I need a link from the marker - like index.php?main_page=index&cPath=66 to open the assosiated product category below the map.

In other words, I need the product category page to open alone without zc sideboxes and headers.

I would appreciate your help.

Thanks

Andy
05 Apr 2007, 05:30
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: iFrame - Forbidden error

Here's one method you could try ... keeping your existing iframe approach:

1. set all your GM url's to have another parameter on them, such as: &dmode=inline
ie: index.php?main_page=index&cPath=66&dmode=inline

2. edit your custom template's tpl_main_page.php file:
Find this section:
// the following IF statement can be duplicated/modified as needed to set additional flags
  if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
    $flag_disable_right = true;
  }
Add this below it:
  if (isset($_GET['dmode']) && $_GET['dmode'] == 'inline') {
    $flag_disable_left = true;
    $flag_disable_right = true;
    $flag_disable_header = true;
    $flag_disable_footer = true;
  }



That'll cause only the links generated from the map to display without any header, footer, left, or right sidebox data.
05 Apr 2007, 05:38
#7
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: iFrame - Forbidden error

Thank you, I will try this. What is the correct link to place within an iframe? Should it be like:

<iframe .... src="index.php?main_page=index&cPath=66&dmode=inline"...></iframe>?

or could I reference it directly to the template file?
05 Apr 2007, 05:53
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: iFrame - Forbidden error

Step back a second ....

Zen Cart's infrastructure auto-selects which template to use based on the URL parameters.
It starts from index.php
In the case of the URL you're proposing: index.php?main_page=index&cPath=66
...
main_page=index tells it to use tpl_index_default
but, since cPath is specified, it flips over to using either tpl_index_product_list.php or tpl_index_categories.php and a few others such as tpl_modules_category_row.php and so on.

But, before that even happens, all pages start from tpl_main_page.php, which builds header, left-sideboxes, then main content from the page template (just mentioned above), then right-sideboxes, then footer.

By adding the code suggested earlier, the dmode=inline switch will cause tpl_main_page to "only" display the content for the category number 66.

Thus, you don't need to reference a specific template/template-file. You just use the URL.

As for what to put in the iframe SRC parameter, I suspect that the URL you mentioned in your last post will be fine. It's likely wise to use the complete URL, including http: //domain_name etc...
05 Apr 2007, 10:20
#9
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: iFrame - Forbidden error

DrByte, Thanks you for the great solution, which saved a lot of my time! Highly appreciated! A few questions regarding that iframe structure:

1) now i have to add "&mode=inline" to all the links from products/categories listied within the iframe. Is there a some shortcut rather than finding all the instances of the 'products_id=' in <a href> links?

2) how can I pass session variables from the main zc body to the iframe? Calling the system SESSION vars from within the iframe does not work. Should I specify some specific session name? By default, session from the iframe refer to the PHPSESSID.

Thanks again for your help

Andy
05 Apr 2007, 10:34
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: iFrame - Forbidden error

Now you're making it a whole lot more complex.

Again, Zen Cart isn't designed to operate within an iframe, especially since there are session implications etc.

What exactly are visitors supposed to do after clicking on a link in your map? You mentioned that that's supposed to bring up a list of categories below the map. Then what? And after that, what? And again after that, what? ... and ... and ... then what?

And ... what about regular navigation things on the normal sideboxes?

I was of the impression that the iframe was *inside* other Zen Cart pages. Is that still correct? What interaction is supposed to take place between inner and outer sections?


(I think you're going to need to get a lot more familiar with the inner workings of PHP and Zen Cart if you want to make the rest of that work.)
09 Apr 2007, 08:53
#11
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: iFrame - Forbidden error

I would appreciate you to explain a simple thing - how to pass the system session variabes to the iFrame.

You are right the iframe will be inside other zen pages. Clicking on the map should trigger the root category displayed within the iframe. Clicking on the underlying products within the same category (iframe) should open the products in the same iframe. Only, when the visitor click on the checkpout button, it will jump out to the "normal" zc mode (no iframes).

This "map" mode goes in linw with the normal zc mode (no iframes) when the categories (products) are selected from the sideboxes
10 Apr 2007, 16:48
#12
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: iFrame - Forbidden error

You'll need to change it so all your HREF links include the zenid so that the session is maintained in both places.

You'll also have to relax security so that sessions aren't regenerated. But then you run the risk of more than one customer using same session at a given time, which then means one customer can steal another customer's personal/private data. You probably don't want that.

Nevertheless, passing the zenid on all your URLs should link the sessions.
11 Apr 2007, 09:56
#13
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: iFrame - Forbidden error

everything works fine, while it required quite a big code modification through all links, buttons etc. I am a bit confused by the session (zenid) on all the links. When I delete cookies, it shows me the zenid on all products (categories). However, after i click on any links, all the '&zenid=....' disappear unless i delete cookies again. I am not talking about iframe links - just normal zc pages. In other words, it shows only once.

Where should i take a look to fix this?

Thanks

Andy
11 Apr 2007, 11:02
#14
andy1234 avatar

andy1234

Zen Follower

Join Date:
Oct 2006
Posts:
148
Plugin Contributions:
0

Re: iFrame - Forbidden error

i have been browsing some zenid related posts and it seems to be normal to hide the zenid after the 1st click. The reason why i am confused is because it shows on ALL my links on other sites (zen 1.3.5). But this particular installation is 1.3.7. All the settings are the same and all the sites run on the same server.

Are there any changes in 1.3.7 in terms of zenid session behavior?
12 Apr 2007, 06:21
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: iFrame - Forbidden error

andy1234:

i have been browsing some zenid related posts and it seems to be normal to hide the zenid after the 1st click.
Yes, that is normal, and entirely intentional and desired for security reasons.
This has always been how it works.

If your older site isn't doing that, then it may have some cookie configuration setting problems or perhaps your domain configuration on your hosting account may be incorrect.

I see you've started another thread on this topic here:
http://www.zen-cart.com/forum/showthread.php?t=62984
12 Jun 2007, 14:36
#16
briohny12 avatar

briohny12

New Zenner

Join Date:
Jun 2007
Posts:
48
Plugin Contributions:
0

Re: iFrame - Forbidden error

Hi Dr Byte,

Hopefully you can help me. I don't want to use iframes, so instead I pulled all the php code from the zencart index.php file and put it in my new index.php page which already has a fancy header and side navigation menu. I inserted the php code into a table cell.

The following error came up:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at D:\inetpub\surfworld\onlineshop\test.php:98) in D:\inetpub\surfworld\onlineshop\includes\functions\sessions.php on line 108

Warning: Cannot modify header information - headers already sent by (output started at D:\inetpub\surfworld\onlineshop\test.php:98) in D:\inetpub\surfworld\onlineshop\includes\init_includes\init_templates.php on line 78


Now I understand what it is saying because obviously my new index.php page already has a head, title, body section etc. My problem is that I'm not very good with PHP and I'm not sure what to fix in the code. Are you able to help please?

Thanks
Briohny
12 Jun 2007, 15:14
#17
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
1

Re: iFrame - Forbidden error

rather than try to re-invent the wheel ( the zen cart function )
pull your kool header and columns into ZC that would be MUCH easier
12 Jun 2007, 15:25
#18
briohny12 avatar

briohny12

New Zenner

Join Date:
Jun 2007
Posts:
48
Plugin Contributions:
0

Re: iFrame - Forbidden error

Thanks Merlinpa 1969,

That's what I kind of did but I only pulled them into the index.php file. How do I pull my header and nav menu into zencart so that the shop is displayed with the header and nav menu on every page? Do I have to adjust a template page or something?

Sorry, very amature.

Thanks again.
13 Jun 2007, 04:18
#19
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,506
Plugin Contributions:
173

Re: iFrame - Forbidden error

As for the "headers already sent" message, refer to this FAQ:
https://www.zen-cart.com/tutorials/index.php?article=87

Briohny12:

How do I pull my header and nav menu into zencart so that the shop is displayed with the header and nav menu on every page? Do I have to adjust a template page or something?
Yes - /includes/templates/YOURTEMPLATE/common/tpl_header.php would be the place to do that, as it draws the header of every page.

As for the templating system, there are a number of FAQs to help you:
https://www.zen-cart.com/tutorials/index.php?category=16
https://www.zen-cart.com/tutorials/index.php?article=232
https://www.zen-cart.com/tutorials/index.php?article=143
https://www.zen-cart.com/tutorials/index.php?article=230
http://www.zen-cart.com/wiki/index.php/Customisation_-_Templates
15 Jun 2007, 16:27
#20
briohny12 avatar

briohny12

New Zenner

Join Date:
Jun 2007
Posts:
48
Plugin Contributions:
0

Re: iFrame - Forbidden error

Ok... so i'm having problems trying to format the layout of my page. I'm trying to customise the area outside of the cart. Using frames would be easy, but I don't want to go down that route.

So far, I edited my tpl_header.php. I can successfully add on any banner, flash banner, logo whatever to the top of the .php script. However, I cannot for the life of me get a left navigation menu to appear.

I have tried tables, breaking down the script and calling as separate include files, div tags & CSS formatting. Nothing seems to work. The top banner displays perfectly but the shop is all out-of-whack when I try to add a left navigation menu.

I have attached a mock of what I want the final shop to look like. As you can see, there is a banner and then a left navigation menu with the cart to the right of this.

Can anyone help me please.

:blink: