Topic: Passing Parameters in URL (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=29020" title="Pages that link to Topic: Passing Parameters in URL (Page 1 of 1)" rel="nofollow" >Topic: Passing Parameters in URL <span class="small">(Page 1 of 1)</span>\

 
SleepingWolf
Paranoid (IV) Inmate

From:
Insane since: Jul 2006

posted posted 03-04-2007 23:49

Not sure where the hell to post this. I'm trying to create links to pages on my site that will switch the theme at the same time. I can do this for the blog index page, but I would like to be able to do it for any page in the blog.

Is there a way to pass parameters in the url to do this? I've tried various operators but no luck.

For example, these 2 links switch themes but only for the index page.

http://www.sleepingwolves.com/blog/index.php?wptheme=Default


http://www.sleepingwolves.com/blog/index.php?wptheme=Travel

Nature & Travel Photography
Visit the Sleeping Wolves

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 03-04-2007 23:54

Not sure I understand the question.
Do you have an example of what you are trying that does not work?

Bottom line is that if you pass a parameter through the URL, the page will need some mechanism to interpret that paramater and respond accordingly...

SleepingWolf
Paranoid (IV) Inmate

From:
Insane since: Jul 2006

posted posted 03-05-2007 00:08

Hey DL

I'm trying to switch the site theme within the url.

The links above will take you to my blog - each link will change the Wordpress Theme in the process.

The problem is that they both take me to the same page..the index page.

What I would like to do, is go to any page and have it served with either theme not just the index page.


For example, and this doesn't work:

http://www.sleepingwolves.com/blog/?page_id=134+wptheme=Travel

although this does
http://www.sleepingwolves.com/blog/?page_id=134+wptheme=Default
Nature & Travel Photography
Visit the Sleeping Wolves

(Edited by SleepingWolf on 03-05-2007 00:10)

Moon Shadow
Paranoid (IV) Inmate

From: Paris, France
Insane since: Jan 2003

posted posted 03-05-2007 00:28

I'm not sure I fully understood what you want... Let me know if this was useful



I'm not familiar with WordPress, but I believe it is set up works like any other blog.

There should be a config file somewhere storing your preferences. You have to find the variable that holds the name of the theme, say $themeName. All you have to do is to modify the code to check whether a $_GET variable is passed in the url or not, and change the value of the variable according to that.

Final step, link to a page using the name of the variable.
http://www.sleepingwolves.com/blog/index.php?themeName=whatever for this example.


Please note that you'll have to edit the script that modify your preferences too, or it may return an error next time you use it.

Also be careful of what you do with $_GET variables, and never trust user input.

----
If wishes were fishes, we'd all cast nets.



(Edited by Moon Shadow on 03-05-2007 00:28)

SleepingWolf
Paranoid (IV) Inmate

From:
Insane since: Jul 2006

posted posted 03-05-2007 00:50

Hey Moon Shadow

I'll try again to make this clearer - sorry if it sounds confusing.

Wordpress themes are normally changed through an admin module (wp-admin).

Users don't have access to this module but you can allow users to change the themes to their preferences through a theme switcher plugin that allows the user to change themes from a dropdown.

I'm doing something different. I don't want the dropdown. Instead, I want the user to click a link which will then switch the theme (this is done with cookies). I can do this using the following syntax:

http://www.sleepingwolves.com/blog/index.php?wptheme=Travel

where Travel is a optional theme.

so far so good, but this takes me back to the same page - the index page.
what if i want to go to page 534 instead of the index page? that's the question i'm trying to solve.



Nature & Travel Photography
Visit the Sleeping Wolves

Moon Shadow
Paranoid (IV) Inmate

From: Paris, France
Insane since: Jan 2003

posted posted 03-05-2007 01:45

Ahhh - makes more sense to me

I guess Wordpress uses the same header file for all pages, so that would be a good place to add a little snippet before the theme is loaded.

Just check if the $_GET variable is present, if so modify the cookie to reflect the theme change, and the page will be loaded with the new theme.


edit : grammar, grammar.. duh.

----
If wishes were fishes, we'd all cast nets.



(Edited by Moon Shadow on 03-05-2007 01:52)

(Edited by Moon Shadow on 03-05-2007 01:53)

(Edited by Moon Shadow on 03-05-2007 01:54)

DL-44
Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 03-05-2007 04:10

Not being privy to the backend code used to parse the variables sent via the URL, I can't really say what you need to do. I would say you will find your answer by digging through that code and making sure the right bits are inplace where they need to be...

twItch^
Maniac (V) Mad Scientist

From: Denver, CO, USA
Insane since: Aug 2000

posted posted 03-05-2007 04:17

Erm... if you're trying to pass two (or more) variables through the querystring, the syntax is thus:

http://www.foobar.com/index.php?foo=bar&bar=foo

That *sounds* like the problem you're having.

Therefore,

http://www.sleepingwolves.com/blog/?page_id=134+wptheme=Travel

should be

http://www.sleepingwolves.com/blog/?page_id=134&wptheme=Travel



Is that what you're trying to accomplish?

-steve

SleepingWolf
Paranoid (IV) Inmate

From:
Insane since: Jul 2006

posted posted 03-05-2007 05:08

Steve:

That's exactly what i'm trying to do - but no matter what page you put in the url you will be redirected to
http://www.sleepingwolves.com/blog/


How would I hit this page for example:
http://www.sleepingwolves.com/blog/?cat=7&paged=3
It will still take me back to the blog's index page


Desired Target If i use this:
http://www.sleepingwolves.com/blog/?cat=7&paged=3&wptheme=Default

I get this Incorrect/Resulting Page- Blog Index:
http://www.sleepingwolves.com/blog/

Nature & Travel Photography
Visit the Sleeping Wolves

(Edited by SleepingWolf on 03-05-2007 05:32)

twItch^
Maniac (V) Mad Scientist

From: Denver, CO, USA
Insane since: Aug 2000

posted posted 03-05-2007 17:33

Sounds like an .htaccess problem where you've used some sort of redirection. Or index.php includes a redirect.

-steve



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu