N
N
Nikolai Dobrynin2020-01-09 13:47:01
MODX
Nikolai Dobrynin, 2020-01-09 13:47:01

ModxRevo, how to make #anchor work on a website page?

There is a project of a not quite standard layout, the entire layout is crammed with anchors of the form. Accordingly, the page url looks like siteurl.by/#main , these same anchors are on all pages, and therefore, when trying to refresh the page, it always redirects to the main one, because the url has a # symbol on On the documentation page, I found a plugin that should fix this problem. But it doesn't work here is his code<a href="#main">Ссылка</a>

<?php
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);
}

This code should check if we are on the main page, and if not, substitute the alias of the current page in the url. But it doesn't work.
I also tried to prescribe this construction in the base url. It allows you to update the page, however, when you navigate through the menu, every 2nd transition jumps to the main one. tell me where to dig, Google advises some kind of game and nothing but the documentation page could not be found. <base href="http://askmeplz.com/" />

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Tarasov, 2020-01-09
@an-tar

What system event is the plugin configured for?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question