<![CDATA[ Links referring to anchors on the same page - How to? - MODX Community Forums]]> https://forums.modx.com/thread/?thread=30297 <![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563307 BobRay Dec 18, 2018, 07:35 PM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563307 <![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563184 Quote from: BobRay at Dec 04, 2018, 06:13 AM
See if this makes a difference:...
Thanks BobRay for your quick reply.

Sorry,
there was 1 word to much in my posting above. Now I emended it to "I could manage to get this work."
So I hope your code and my code can help others.

The important thing was to make it work for folders also:
$newOutput=str_replace('/#', '#', $newOutput); //if the page is a folder!!!


Seems to be OK:
$modx->makeUrl($modx->resource->get('id'))
]]>
androme16 Dec 10, 2018, 05:51 PM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563184
<![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563069
$modx->makeUrl($modx->resource->get('id'), "", "", "full");


Is your plugin attached to OnWebPagePrerender?

If that doesn't work, you can always put this at the top of the page in your template:

<a name="top"></a>


Then do this in your plugin:

if($modx->resource->get('id') !=$modx->config['site_start']) //not on Startpage
{
   $newOutput=str_replace('href="#', 'href="' .$modx->makeUrl($modx->resource->get('id'), "", "", "full") .'#top', $modx->resource->_output);
   $newOutput=str_replace('/#', '#top', $newOutput); //if the page is a folder!!!
   $modx->resource->_output = $newOutput;
}
]]>
BobRay Dec 04, 2018, 06:13 AM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563069
<![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563066 Quote from: sottwell at Oct 06, 2011, 01:25 AM
http://modx.com/extras/package/baseurlsamepagelinkfix

I could not manage to get this work.

My code is:
if($modx->resource->get('id') !=$modx->config['site_start']) //not on Startpage
{
   $newOutput=str_replace('href="#', 'href="' .$modx->makeUrl($modx->resource->get('id')) .'#', $modx->resource->_output);
   $newOutput=str_replace('/#', '#', $newOutput); //if the page is a folder!!!
   $modx->resource->_output = $newOutput;
}


derived from:
https://docs.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/resources/named-anchor]]>
androme16 Dec 03, 2018, 08:18 PM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-563066
<![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-396047 http://modx.com/extras/package/baseurlsamepagelinkfix]]> sottwell Oct 06, 2011, 01:25 AM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-396047 <![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-391716
$source = &$modx->documentOutput;

with this
$source = &$modx->resource->_output;

]]>
Paavo Aug 29, 2011, 11:28 AM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-391716
<![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164266 aellis1 Jul 21, 2011, 05:57 PM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164266 <![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164265
In Evo there is a package to solve this problem I have seen here: http://modxcms.com/extras/package/41

Is there a similar solution for Revo, too?

Gerdi smiley]]>
Gerdi Oct 20, 2010, 05:27 PM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164265
<![CDATA[Re: Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164264
<a href="[[~[[*id]]]]#anchor">anchor</a>


oops sorry should have read your question better.

So you would like a plugin that converts "#anchor" to the proper url? - sorry I’m unaware of one for revo yet.

Wouldn’t a quick search and replace be sufficient for an import?]]>
graydesign Oct 20, 2010, 05:22 PM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164264
<![CDATA[Links referring to anchors on the same page - How to?]]> https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164263
In our MODx-Revolution it works only by adding <a href="[[~page-id]]]#anchor">Anchor</a>

Our goal is to import a webpage including about 1.000 anchors with the syntax <a href="#anchor">. Because of this it would be great if we could keep this syntax.

Does anybody know how to make this work?

Gerdi smiley]]>
Gerdi Oct 20, 2010, 05:06 PM https://forums.modx.com/thread/30297/links-referring-to-anchors-on-the-same-page---how-to#dis-post-164263