Forums / Cotonti / Support / Global tag url creation

foxhound
#1 2012-08-30 13:36

I hope with my title I correctly show what it is I am looking for smiley

Anyway, I have this: {PHP.pag.page_id|cot_url('page','id=$this')} to create an url of the curent page I am viewing. However, Sienna uses a different link.
For example for xx page the url looks like this: index.php?e=page&c=news&al=My-second-newspost
With {PHP.pag.page_id|cot_url('page','id=$this')} the url returned is index.php?e=page&id=3
The page_id is correct, but the url is not the same as how it was first displayed ( index.php?e=page&c=news&al=My-second-newspost )

I would like to use that global tag to recreate the url but so far I have not really been lucky (lucky literally cause I am not really sure about what I am doing).
I have tried many different versions of this: {PHP.pag.page_id|cot_url('page','c=$pag_cat','al=$pag_alias')} but that creates weird urls like this: index.php?e=page&c=%24pag_catal=$pag_alias

Anyone has an idea how to adjust the global tag so the proper url is returned?

In case anyone wonders, I need this so when i click "go to top" the browser knows I want to stay on the same page (url is equal) and so a nice scoller effect is used to go to the top instead of reloading the page to the top.
I use the scoller from symisun-03 but that one does also not work correctly, cause it uses that global tag to re-create the url which is wrong. So first it reloads the page to index.php?e=page&id=3 and than if you click the "go to top" link the scoller comes into affect cause a link on the same page is activated (you are on index.php?e=page&id=3 and the global tag recreates exactly that).

I hope the above is clear.........a bit. If anyone knows how to do this I would appreciate a little assistance.

[add on]
{PAGE_URL} does not work in the footer (where the "go to top" is), thats why i am using this global tag.

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
This post was edited by foxhound (2012-08-30 13:55, 11 years ago)
tensh
#2 2012-08-30 16:00

Damn, it's not that easy as it might seem. I spent an hour trying to figure it out. 

Catch this plugin: Page url by alias

Usage: {PHP.pag.page_alias|pageurl($this)} or just {PHP|pageurl('youraliasintext')}

I'm not sure if it's a correct approach since it makes a call to database to determine the page category. Anybody can comment on this?

GHengeveld
#3 2012-08-30 17:39
If you simply want the URL of the current page, try this: {PHP._SERVER.REQUEST_URI}
tensh
#4 2012-08-30 18:16

I just knew there was a more simple way ^^

foxhound
#5 2012-08-31 11:13

@tensh
Thank you very much for the help, I appreciate your effort.
Maybe that plugin will come handy in other cases, maybe the tip by GHengeveld will make it absolete.

@GHengeveld
Thanks, that seems to do wonders and also will prevent me having to use multiple if / else statements depending on which tpl the visitor is smiley

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
GHengeveld
#6 2012-08-31 16:50
It never hurts to experiment with plugins, I'm happy to see people building stuff like that to help each other out. Plus its great exercise.