e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
321 stars 213 forks source link

Links inside a page <a href=#one> #3017

Closed Nastradoomus closed 4 years ago

Nastradoomus commented 6 years ago

Hi

I've been looking for a simple CMS with bootstrap and so here i am. The first thing i checked was internal links which is quite important working with bootstrap and straight away a problem occured.

Links in top menu are tampered so that e107 automatically adds site location in front of the #link. If someone uses internal #link as a link i don't think that it is logical for the software to change this.

i.ex.

<li>
  <a class="page-scroll" role="button" href="http://www.yoursite.com/#one" title="">Test</a>
</li>

This breaks the page-scroll.

should be justhref="#one".

Now i can change this but it takes a lot of time to search where everything is constructed and change the code. Specially when you're just trying to figure out what software to use. I already tried to search in the files where {LINK_URL} is constructed but it wasn't that easy.

Jimmi08 commented 6 years ago
// Main Link - active state
$NAVIGATION_TEMPLATE['main']['item_active'] = '
    <li class="page-scroll active">
        <a class="e-tip" role="button"  data-target="{LINK_TARGET}" href="{LINK_URL}"{LINK_OPEN} title="{LINK_DESCRIPTION}">
         {LINK_ICON} {LINK_NAME}
        </a>
    </li>
';
Nastradoomus commented 6 years ago

Yes i know. This is where the link html is constructed but i'm talking about {LINK_URL}. The link itself does not contain anything else than #link. No http://www.yoursite.com. It comes from somewhere. Where is this {LINK_URL} constructed?

Jimmi08 commented 6 years ago

With multipage site you have to use full url http://www.yoursite.com/#contact and use target attribute to get page scrolling to work.

If you look something like this, it's shortcode, so look for method sc_link_url. And you find it in e107_handlers/sitelinks_class.php

Live example that this works: https://themes.e107.org/agency/#contact

Of course, standard script for page scroll from one page templates doesn't work. You need to have script that works for multipage solutions. {LINK_TARGET} - is important to use.

Nastradoomus commented 6 years ago

There is something odd going on in my install?

jquery.min.js:2 Uncaught Error: Syntax error, unrecognized expression: http://my.home.site.com/portal/index.php#three
    at Function.fa.error (jquery.min.js:2)
    at fa.tokenize (jquery.min.js:2)
    at fa.select (jquery.min.js:2)
    at Function.fa [as find] (jquery.min.js:2)
    at n.fn.init.find (jquery.min.js:2)
    at new n.fn.init (jquery.min.js:2)
    at n (jquery.min.js:2)
    at HTMLAnchorElement.<anonymous> (scripts.js?0:20)
    at HTMLAnchorElement.dispatch (jquery.min.js:3)
    at HTMLAnchorElement.r.handle (jquery.min.js:3)

Edit: Now i get it. Javascript throws an error and it reloads the page after i click the link and then it scrolls down to the actual #link. I have to modify this. It's not very smooth. It should check if we are on that actual page the #link refers and act accordingly.

If you use only #link as the target smooth scroll does not work at all.

In your example it works like it should.

Jimmi08 commented 6 years ago

Edit: Now i get it. Javascript throws an error and it reloads the page after i click the link and then it scrolls down to the actual #link. I have to modify this. It's not very smooth. It should check if we are on that actual page the #link refers and act accordingly.

It's not core thing, your theme should do this.

In your example it works like it should.

it's done by theme javascript.

Moc commented 6 years ago

@Nastradoomus Has your question been answered? :)