Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / set_snapshot - can I use it for scripts outside of index.php?

set_snapshot - can I use it for scripts outside of index.php?

Views: 2,100

Results 1 to 20 of 30
5 Aug 2015, 2:10 PM
#1
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

set_snapshot - can I use it for scripts outside of index.php?

I have been trying to figure it out myself, but I can't :no:

$_SESSION['navigation']->set_snapshot();

If I just set that, it seems to strip out the base page, I don't want it to strip the base page, please help.

So if page was...

website.com/module_here.php?variable=3333

it snapshots

website.com/?variable=3333

I want the snapshot to redirect back to the previous page and not strip any information out.

5 Aug 2015, 4:06 PM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: set_snapshot - can I use it for scripts outside of index.php?

DigitalShadow:

I have been trying to figure it out myself, but I can't :no:

$_SESSION['navigation']->set_snapshot();

If I just set that, it seems to strip out the base page, I don't want it to strip the base page, please help.

So if page was...

website.com/module_here.php?variable=3333

it snapshots

website.com/?variable=3333

I want the snapshot to redirect back to the previous page and not strip any information out.

In your call to set_snapshot() if the page you are on does not include main_page= and it is not index.php, then need to provide the array information associated with the page that you are on...

These are the fields "reviewed":

 
'page' => $page['page'],
'mode' => $page['mode'],
'get' => $page['get'],
'post' => $page['post']);

Take a look at how it is done in: includes/modules/pages/checkout_payment_address/header_php.php around line 27.

The array method allows storing the get data as well as any post data that is considered necessary to return to the same "page"...

The function exists in includes/classes/navigation_history.php

6 Aug 2015, 12:54 PM
#3
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

I tried that, it didn't work...

$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_ORDER_QUESTION));

redirects to

/index.php?main_page=order_question.php

when it should redirect to

/order_question.php?order_id=#######

6 Aug 2015, 1:07 PM
#4
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => $_SERVER['REQUEST_URI']));

That correctly now passes the page, but I need to remove "/index.php?main_page="

/index.php?main_page=/order_question.php?order_id=######

6 Aug 2015, 1:16 PM
#5
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

Do I need to set path as well?

6 Aug 2015, 1:32 PM
#6
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: set_snapshot - can I use it for scripts outside of index.php?

but I need to remove "/index.php?main_page="
Why/what purpose do you have for needing to remove this??

6 Aug 2015, 1:33 PM
#7
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

Due to the way the module is designed. The url doesn't include index...etc

6 Aug 2015, 1:41 PM
#8
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

Is it not possible to redirect without /index.php?main_page= ?

6 Aug 2015, 1:42 PM
#9
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: set_snapshot - can I use it for scripts outside of index.php?

Due to the way the module is designed
What module??

Maybe you should answer/provide the information in posting tips available when you post

6 Aug 2015, 1:47 PM
#10
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

Sorry I thought using the snapshot call was a core zen file and wouldn't require me to include further information.

The plugin is outdated however, I wouldn't say it is broken. It is old and it may not follow the current correct practices regarding zen integration, so I didn't want to drag the module into the equation. Order Questions

I hoped it would be possible to set a snapshot to enable a customer to login and then return back to this form to comment on their order. Is it not possible to set a snapshot that doesn't include /index.php?main_page=

6 Aug 2015, 1:56 PM
#11
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: set_snapshot - can I use it for scripts outside of index.php?

DigitalShadow:

That correctly now passes the page, but I need to remove "/index.php?main_page="
If you can correctly get the page - again why do you have to remove this??
mc12345678:

In your call to set_snapshot() if the page you are on does not include main_page= and it is not index.php, then need to provide the array information associated with the page that you are on...
DigitalShadow:

Is it not possible to set a snapshot that doesn't include /index.php?main_page=
What is the url when the page is first loaded - before you set "snapshot" -
If it includes "index.php?main_page=" then the answer is no

6 Aug 2015, 1:58 PM
#12
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

I follow a link sent from email, it directs me to

domain.here/order_question.php?order_id=######

If the customer is not logged in, then this is set

$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => $_SERVER['REQUEST_URI']));

and after login I am redirected to

domain.here/index.php?main_page=/order_question.php?order_id=######

which obviously isn't what I wanted.

6 Aug 2015, 2:00 PM
#13
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: set_snapshot - can I use it for scripts outside of index.php?

Read the post by mc12345678

mc12345678:

In your call to set_snapshot() if the page you are on does not include main_page= and it is not index.php, then need to provide the array information associated with the page that you are on...

6 Aug 2015, 2:09 PM
#14
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

I read that, however, understanding how to implement this is another thing altogether.

Could you please explain to me how I would apply that in this situation.

I had already had my head buried in

includes/modules/pages/checkout_payment_address/header_php.php

and

includes/classes/navigation_history.php

for a couple of days trying to figure out how to do it myself before I posted here. I arrive at this point having exhausted my limited understanding of arrays and how to use them to pass data.

I would deeply appreciate you explaining how to use those functions to pass the correct information.

Thank you

6 Aug 2015, 2:12 PM
#15
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: set_snapshot - can I use it for scripts outside of index.php?

kobra:

Read the post by mc12345678

DigitalShadow:

Do I need to set path as well?

Thinking about the overall process with ZC these days, basically it operates under the control of index.php... So why is this additional "code" not in its own main_page? (BTW, FILENAME_ORDER_QUESTION should not include the .php suffix... if necessary in specific situations then it could be appended, but if you notice how other FILENAME_XXX definitions are made in a standard ZC, they do not include the extension.)

Anyways, point is, that ZC basically expects index.php to be the file in question and to direct/redirect to the applicable main_page based on that information.

I'm at least one message behind, but basically you would want to move the code/function of order.php into it's own page, even if that page was to redirect back to the original file...

Checkout this wiki on adding pages: https://www.zen-cart.com/wiki/index.php/Creating_new_pages

6 Aug 2015, 2:18 PM
#16
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

I've already made a couple of new pages, however, I was trying to avoid having to do that with this if at all possible.

6 Aug 2015, 2:25 PM
#17
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: set_snapshot - can I use it for scripts outside of index.php?

Deleted because of posting glitch, content was previously provided an alternate way.

6 Aug 2015, 2:26 PM
#18
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

debug shows the following

logoff?
login?
index?order_id=35041&


SSL /order_question.php?order_id=35041?

and

$_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => $_SERVER['REQUEST_URI']));  echo $_SESSION['navigation']->snapshot['page'];

shows

/order_question.php?order_id=35041

6 Aug 2015, 2:30 PM
#19
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: set_snapshot - can I use it for scripts outside of index.php?

DigitalShadow:

I've already made a couple of new pages, however, I was trying to avoid having to do that with this if at all possible.

Really could be as simple as creating the additional page with the content of the additional page to zen_redirect to your current page...

I've been trying to dig into the navigation_history function to figure out what other command/control could be offered to get to a page other than index.php?main_page=, but haven't found the code that processes back the information to be able to offer an alternate solution...

So far have seen a few ways to address this and not lose the capability of the link currently out there (customers that have previously ordered would still want to be able to follow the link or be provided updated information on how to get to the information). But, I can't say that I see how the $page array can contain any further information to redirect to the original desired file directly in that assignment as I believe that the redirect in uri option is no longer available if it ever was...

6 Aug 2015, 2:40 PM
#20
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: set_snapshot - can I use it for scripts outside of index.php?

the snapshot page is showing as correct, but it seems to want to place the page on a base path that needs to be set.