[dokuwiki] Re: Is there a Dokuwiki event when you click on a link?

  • From: Chris G <cl@xxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 16 Jun 2010 18:34:08 +0100

On Wed, Jun 16, 2010 at 04:14:56PM +0200, Doogie wrote:
> 
> On Wed, 16 Jun 2010 12:55:53 +0100, Chris G <cl@xxxxxxxx> wrote:
> > However ACTION_ACT_PREPROCESS doesn't happen early enough.
> > 
> > I want to 'catch' a non-existent link and do things with it before
> > getting messages about it being non-existent etc.
> > 
> > As it is, using ACTION_ACT_PREPROCESS, I get to the "this page does
> > not exist" message from DokuWiki before my plugin code even gets a
> > look in.
> > 
> > Will DOKUWIKI_STARTED happen earlier?  I've just tried it, no.
> > Chris Green
> 
> Hi Chris!
> 
> This is not a DokuWiki Problem, but the "usual" HTTP Roundtrip. Think of
> it this way: 
> 
> 1. User clicks on a link on the page
> 2. (the javascript 'onclick' event is fired in the browser - more on this
> below :-)
> 3. then the browser sends an HTTP request to the server
> 4. the server routes this request (in the end) to the doku.php script
> 
> --- now the PHP compiler is running on your server---
> 5. The doku.php script does some initialisation for dokuwiki
> 6. dokuwiki events are fired ACTION_ACT_PREPROCESS,  DOKUWIKI_STARTED
> 
> If the link points to a nonexistant URL on your server, then the process
> diverts in step 4.
> 
But does it?  It points to something like:-

    http://this.isbd.net/boatWiki/doku.php?id=playground%3Astart

> 4a) url not found
> 5a) HTTP server forward to 404 error page
> 
So the URL *is* found isn't it as doku.php has got control and it's
that PHP which generates the HTML that the browser gets to display.

Various DokuWiki plugins claim to 'trap' 404 and similar things so it
seems it should be possible to do what I want.  I do some more playing
with these plugins and see what I learn.

> -------------------
> 
> 
> ============ Java Script ========
> The hook you are looking for is step 2: the JavaScript Event: When the
> user clicks on a link on a page, then you can execute some JavaScript
> function. This function then can check if the target url exists, and maybe
> do something, when this page does not exist.
> 
> 
> <script type="text/javascript">
>   function checkPage(source) {
>      var url = source.src;
> 
>      // here comes a very clever implementation of maybe this forum post:
>      // http://www.webdeveloper.com/forum/showthread.php?t=165298
> 
>   }
> </script>
> 
> <a href="http://www.noexistantpage.de/foobar.html";
> onclick="javascript:checkPage(this)">
> 
> 
> 
> I think now I completely lost you, did I? :-) Hopefully not.  Happy
> coding.
> 
No, you didn't lose me completely, I was originally wondering if I was
trying to do something impossible and it may well be that I am.  This
E-Mail thread is very useful though at improving my understanding of
what's going on.

-- 
Chris Green

-- 
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: