PDA

View Full Version : Link to "this page"?


Morrus
11-18-2013, 12:10 AM
Probably a very simple, silly question. I made a a toggle to switch styles at the top of my forum (depending which style you're in, it's just a pair of conditional links to the URl of the home page with ?styleid=x after it).

It works fine, but takes people to the home page when they click on it. What would I need to use for the URL to keep the user on the same page, and simply switch the style? I.e., what's the template code which outputs the URL of the page currently being viewed?

Digital Jedi
11-18-2013, 12:31 AM
Try just putting the style changer command in the link:

<a href="?styleid=x">Style X</a>

Morrus
11-18-2013, 01:08 AM
You mean just miss out the part of the URL before the question mark? Currently I have:


<a href="http://www.site.com?styleid=x">Switch Style</a>


--------------- Added 1384741257 at 1384741257 ---------------

Just tried your version. It takes me back to the home page just like my version does, unfortunately.

Digital Jedi
11-18-2013, 03:30 AM
Ah, yes, I wasn't thinking. Actually, there is a way, but you may have to use more if conditions, because ? can only be used once in the URL. Once you instantiate it, you then have to add additional functions with &amp;.


So if a user is on this page (forumdisplay.php?3-D-amp-D-and-Pathfinder), the code would need to look like this:
<a href="{vb:raw relpath}&amp;styleid=X">Style X</a>

But if he's on this page (blog.php), it needs to look like this.
<a href="{vb:raw relpath}?styleid=X">Style X</a>

It's doable. But probably more work that you had planned.

Morrus
11-18-2013, 10:38 AM
Eeek, no, you're right - that would be unfeasibly bulky. There' a lot of different pages!

Looks like a return to the home page is going to be necessary then. That's a shame; still, it's not the end of the world! Thanks for the help!

ozzy47
11-18-2013, 11:17 AM
What is the original code you were trying to use?

Morrus
11-18-2013, 12:06 PM
What is the original code you were trying to use?

It's not really code; just a link - the one I posted above:

<a href="http://www.site.com?styleid=x">Switch Style</a>

ozzy47
11-18-2013, 12:09 PM
What about the conditionals?

Morrus
11-18-2013, 01:18 PM
Oh, that just gives a different link depending on the viewing style:

<vb:if condition="$bbuserinfo['styleid']==14"><a href="?styleid=19">Switch Style</a>
<vb:else />
<a href="?styleid=14">Switch Style</a>
</vb:if>

ozzy47
11-18-2013, 01:21 PM
Ok that's what I thought, I'll do some testing when I get home from work.