Not logged in. · Lost password · Register
Forum: General Help and Support Syntax and Usage RSS
Any solution to get "the current URL" ?
Avatar
hemmerling #1
User title: Rolf Hemmerling, Germany
Member since Jul 2009 · 86 posts · Location: Hannover, Germany
Group memberships: Members
Show profile · Link to this post
Subject: Any solution to get "the current URL" ?
Hello,
to use a third-party service like a (free) translating service, its often necessary to add the "current URL" to a link,
like with

http://thirdpartyservice.com?url=current_url_of_my_website

example
http://www.tranexp.com:2000/InterTran?type=url&from=eng&to=ger&url=http://www.dokuwiki.org/plugin:404manager

****
Is there any plugin or built-in option, maybe with help of PHP, to do this ?

Of course I want to avoid to put a link to any of my pages, which contains the hand-written URL of the page.
Because this would increase the administration efford in case of changes.
And I would prefer to put the *same* code to any page, to activate that feature.

And it is no solutoin to put the translation help later in a template, so that there is no link in the dokuwiki .TXT pages, but just in the template framework.
****

So 100% pure PHP code would be ok, but as rookie ( of PHP and Dokuwiki ), its not easy to find maybe the right names of the proper variables... Any hints ?


I found
a)http://www.webcheatsheet.com/PHP/get_current_page_url.php
but the current page of a dokuwiki document is always "doku.php".... or ?

b)The wonderful "this>../path/page" function of Dokuwiki does not help, as the current_page_url is not at the start of a link string.
More important, "this>" is the path to "doku.php" and so does not help much to solve the problem.

Btw, a solution which works with the Dokuwiki "internal niceurl" feature would be great.

So if there is no solution,
what do you suggest, to do, for me as Dokuwiki rookie and PHP rookie
a) write a plugin ?
b) insert some PHP code on any page ?
c) forget about it, its too much advanced for rookies

As I *love* to have a line of flags on my website pages, which offer translation to "any" language even if it is funny.

Sincerely
Rolf
Avatar
andi (Administrator) #2
Member since May 2006 · 2449 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Putting something like this in your template should work.

  1. <?php
  2. echo '<a href="http://someservice.com/foo?url='.rawurlencode(wl($ID)).'">translate</a>';
  3. ?>
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
hemmerling #3
User title: Rolf Hemmerling, Germany
Member since Jul 2009 · 86 posts · Location: Hannover, Germany
Group memberships: Members
Show profile · Link to this post
Thanks alot,

but URL "wl($ID)"
a) is just the URL path from the server root to "doku.php", e.g. "/path/doku.php", so the domain "http://myurl.com" is missing.
b) especially it does not include the "nice URL" path (or the parameters "?id=anything:something").

Any further help to get the complete URL with parameters, by PHP ?
Thanks in advance.

Sincerely
Rolf
This post was edited on 2009-09-25, 21:44 by hemmerling.
Avatar
andi (Administrator) #4
Member since May 2006 · 2449 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by hemmerling:
but URL "wl($ID)"
a) is just the URL path from the server root to "doku.php", e.g. "/path/doku.php", so the domain "http://myurl.com" is missing.

Ahh, my bad. wl($ID,'',true) should work IIRC.

Quote by hemmerling:
b) especially it does not include the "nice URL" path (or the parameters "?id=anything:something").

wl() handles the userewrite option correctly if its that what you mean.
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
hemmerling #5
User title: Rolf Hemmerling, Germany
Member since Jul 2009 · 86 posts · Location: Hannover, Germany
Group memberships: Members
Show profile · Link to this post
Thanks alot,
this new solution gives the full URL to doku.php, e.g.

http://mydomain/mypath/doku.php

but not the parameters ?id=subdirectory:article
nor the full URL in case of "internally generated nice URL".

I would be pleased about any further help.

a)
What I really need to address the external service is a referer to
http://mydomain/mypath/doku.php?id=subdirectory:article
and/or to
http://mydomain/mypath/doku.php/subdirectory/article

b)
What I need for other purposes, e.g. as individual parameter for a feedback email formular, is the name of the path
id=subdirectory:article or subdirectory:article
and/or
/subdirectory/article
(to be put in the "subject" of the email )
as single string, without the domain and the path to doku, php.

If necessary/useful, please point me to an online description of the wl() function, or other useful function. I failed, with google, to find valuable informations about my wishes.

Sincerely
Rolf
This post was edited 4 times, last on 2009-09-26, 18:42 by hemmerling.
Avatar
hemmerling #6
User title: Rolf Hemmerling, Germany
Member since Jul 2009 · 86 posts · Location: Hannover, Germany
Group memberships: Members
Show profile · Link to this post
So please tell me, how to get the complete URL including the dokuwiki parameters  ( alternatively the complete NiceURL).

So that I can refer to the currently loaded page, by putting code in the template,
instead of including the code on "any" page.

Wanted
http://thirdpartyservice.com/?url=current_url_of_my_website

So far, I just get
http://thirdpartyservice.com/?url=path_to_doku.php

,e.g.
path_to_doku.php = http://www.mydomain.de/mypath/doku.php
current_url_of_my_website = http://www.mydomain.de/mypath/doku.php?directory:file
or
current_url_of_my_website = http://www.mydomain.de/mypath/doku.php/directory/file


by your worthy tips.

Sincerely
Rolf
Avatar
ach (Administrator) #7
Member since May 2006 · 1338 posts · Location: London, UK
Group memberships: Administrators, Members, Super Mods, Wiki Managers
Show profile · Link to this post
Quote by hemmerling:
So please tell me, how to get the complete URL including the dokuwiki parameters

As andi wrote:
wl($ID,'',true)

If that doesn't work, you should submit a bug report.
Avatar
hemmerling #8
User title: Rolf Hemmerling, Germany
Member since Jul 2009 · 86 posts · Location: Hannover, Germany
Group memberships: Members
Show profile · Link to this post
Well the whole Dokuwiki system depends on this function wl ($ID),
and it works :-), so it can´t be a bug,

but just a mistake by you, that $ID contains not just the full URL path but also the dokuwiki parameters.

I tested both
2008-05-05 and 2009-02-14b
with the same results:

*******************************
No Space ''
<PHP>
echo wl($ID,'',true);
</PHP>

With Space '  '
<PHP>
echo wl($ID,' ',true);
</PHP>

just displays the URL path without the dokuwiki parameters for the loaded dokuwiki page.

It was interesting to see that the variant with space causes the "?" to be printed too.
But just the "?", not more.
*******************************

It did not help to add more spaces...
Please have a try by yourself.

Is there maybe any interaction between other Dokuwiki parameters, like "Use fully canonical URLs" ? I don´t use that.

So as Dokuwiki and all plugins and templates depends on $ID, you should not change $ID.... if every developer so far expected that $ID just contains the path to the URL without parameters...
probably the Dokuwiki parameters are stored elsewhere or by else means ( or nowhere ??? ).

Especially the Dokuwiki "this>" function must not change, as this is the path to doku.php (without parameters ) !

**********
Is there any description of the $ID and  WL function available ?
If there is no promise, then there is no bug...
**********
Sincerely
Rolf
This post was edited 4 times, last on 2009-10-05, 08:30 by hemmerling.
Avatar
andi (Administrator) #9
Member since May 2006 · 2449 posts · Location: Berlin Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by hemmerling:
<PHP>
echo wl($ID,'',true);
</PHP>

Uhm. You we where talking about modifying your template earlier. Now you're writing page syntax. In the latter case the ID needs to be imported from global scope.

<PHP>
global $ID;
echo wl($ID,'',true);
</PHP>

BTW. there's an API reference. Use it.
Read this if you don't get any useful answers.
Lies dies wenn du keine hilfreichen Antworten bekommst.
Avatar
hemmerling #10
User title: Rolf Hemmerling, Germany
Member since Jul 2009 · 86 posts · Location: Hannover, Germany
Group memberships: Members
Show profile · Link to this post
Thanks alot ! This info was missing.

For all other readers, here is the complete result of my research ( command, result )

1)
<PHP>
echo(wl($ID);
</PHP>

/mypath/doku.php

2) Without space ''
<PHP>
echo(wl($ID,'',true);
</PHP>

http://myhost.com/mypath/doku.php

3) With space ' '
<PHP>
echo(wl($ID,' ',true);   
</PHP>

http://myhost.com/mypath/doku.php?

4)
<PHP>
global $ID;echo wl($ID);   
</PHP>

/mypath/doku.php?id=p:admin.html

5) Without space ''
<PHP>
global $ID; echo wl($ID,'',true);   
</PHP>

http://myhost.com/mypath/doku.php?id=myfile:myfile2.html

6) With space ' '
<PHP>
global $ID;echo wl($ID,' ',true);   
</PHP>

http://myhost.com/mypath/do…?id=myfile:myfile2.html&…

Using a space in the parameter might be delicious...

Sincerely
Rolf
This post was edited on 2009-10-05, 11:08 by hemmerling.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20120620-dev, © 2003-2011 by Yves Goergen
Current time: 2014-04-24, 23:43:23 (UTC +02:00)