[Plugin Development] - Help with query parameters or multiple pages [solved]

staging4hosters

Verified User
Joined
Jul 20, 2019
Messages
12
Hi,

I am trying to create a plugin. I have gone through (I think) all the available documentation for it, but I can't make neither of this to work.
I would appreciate some help, please.

I would like to either have multiple pages(views), like:
/user/plugins/myplugin/
/user/plugins/myplugin/page2
/user/plugins/myplugin/page2/

For changing from one to the next it could be done via button click or javascript redirect.

I have tried creating user/page2.html, user/page2.raw, user/page2/index.html, user/page2/index.raw (chmod +x) and I only get 404 in all cases. The only one that works for me is the user/index.html (or user/index.raw).

Alternatively passing the query parameters would be a valid alternative for achieving what we want.

I have tried redirecting inside the iframe with javascript with
Code:
window.location = '/user/plugins/myplugin?mygetparam=something`;
and also outside of the iframe with
Code:
window.top.location = '/user/plugins/myplugin?mygetparam=something`;

and I get the same issue: the url gets `redirect=yes` appended and then redirected without query parameteres (all query parameters get cleared).

When I do
Code:
echo getenv['QUERY_STRING'];
it is empty.

How could I solve any of this issues?

Thank you very much, best
 
Thank you @Arieh for your reply. I didn't know about the referrer check.

I have tested both options (the query string and the separate page) using window.location.href but they still don't work.
I have checked the request that gets created and the referrer header is included. It contains the ?iframe=yes query parameter, I don't know if that could affect it.

However, I discovered that if instead of linking to
Code:
window.top.location.href = '/user/plugins/myplugin/new';
I link to
Code:
window.top.location.href = '/CMD_PLUGINS/myplugin/new';
then I get this URL at the browser: `/user/plugins/myplugin?path=new', I don't get 404 , but I don't get the content of `user/new.html` , `user/new.raw` or `user/new/index.html` either.

It looks like I am closer, but not there yet...

Thank you anyway.
 
I figured it out!

I have to pass the extension as well:
Code:
window.top.location.href = '/CMD_PLUGINS/myplugin/new.html`;

This works!

I haven't been able to solve the query_string version, but this is good enough.

Thank you!
 
Happy you're getting ahead. Maybe you could try a print_r($_SERVER); and check if there's anything in there. Or, since php 7.1 using getenv() without any parameter, should give back an array of all available vars. I haven't made a DA plugin myself so I don't know any details. Good luck.
 
Thank you again.
I can't get any query_string in the main plugin page, but I can in the other pages, at least using the raw version, there they work fine.
Thanks!
 
Back
Top