We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11054
    • 59 Posts
    I’m not having any success with this. In fact, I’m have a strange scenario.

    The links are being built <a href="[~1~]#anchor">Link</a>. When you click on "link" the anchor becomes the top of the page, and you can’t scroll up, basically chopping off the top half of the page (or anything above the anchor).

    Am I missing something in the implementation of this plug-in? I copied:
    $e= & $modx->Event;
    switch ($e->name) {
    case "OnWebPagePrerender" :
    if($modx->documentIdentifier != $modx->config[’site_start’]) {
    $modx->documentOutput= str_replace(’href="#’, ’href="’ . $_SERVER[’REQUEST_URI’] . ’#’, $modx->documentOutput);
    }
    break;
    }

    Into a new plug-in I called AnchorsAway, and checked OnWebPagePrerender.

    What am I missing?
      • 18383
      • 11 Posts
      This plugin works in Revolution also. Use the first code posted. In Revo in the plugin parameters under "SYSTEM EVENTS" tab tick "OnWebPagePrerender" (last one on the list). That’s the trick.
        • 18503
        • 45 Posts
        I just want to note that for some people running into this issue another option may be to simply add:

        <base href="[(site_url)][~[*id*]~]" />


        to the <head> of their templates (Evolution)
          -dan
          http://wylio.com
          Wylio - Pictures for Bloggers
          • 35606
          • 5 Posts
          I’ve used this a few times; here’s my Revo plugin code (attached to the onWebPagePrerender event)

          if($modx->resource->get('id') != $modx->config['site_start']) {
            $modx->resource->_output = str_replace('href="#', 'href="' . $modx->makeUrl($modx->resource->get('id')) . '#', $modx->resource->_output);
          }
          
            • 10699
            • 15 Posts
            Not sure if anyone is still using this, but if they are...

            In Evolution 1.0.5 the plugin can cause a parse error if the site status is set to "offline" and the "Site unavailable page" is blank... ie: you are using the "Site unavailable message" field.

            The error:
            `` is not numeric and may not be passed to makeUrl()

            This seems to fix it:

            $e= & $modx->Event;
            switch ($e->name) {
                case "OnWebPagePrerender" :
                    if($modx->documentIdentifier != $modx->config['site_start'] && !empty($modx->documentIdentifier)) {
                        $modx->documentOutput= str_replace('href="#', 'href="' . $modx->makeUrl($modx->documentIdentifier) . '#', $modx->documentOutput);
                    }
                    break;
            }
            


            G
            • This is an old thread, but I found a simple solution to this old problem. In MODX Revo, you can simply adjust the "link_tag_scheme" System Setting to "abs" and the base tag is no longer required.
                • 45372
                • 3 Posts
                Quote from: heliotrope at Jul 19, 2007, 08:00 AM
                Hi,

                This one will work without changing the start id page in the plugin code


                <!--?php
                $e= & $modx--->Event;
                switch ($e->name) {
                    case "OnWebPagePrerender" :
                        if($modx->documentIdentifier != $modx->config['site_start']) {
                            $modx->documentOutput= str_replace('href="#', 'href="' . $modx->makeUrl($modx->documentIdentifier) . '#', $modx->documentOutput);
                        }
                        break;
                }
                ?>
                


                :-)
                Thanks man.

                It works perfect. My menu used # links, and this plugin solved the problem