Silex icon indicating copy to clipboard operation
Silex copied to clipboard

Using Anchors

Open Tyrael84 opened this issue 7 years ago • 14 comments

I'm pretty sure I'm close to figuring this out but still not positive.

From what I've gathered you have to use an HTML container, format your text with <a>anchor</a> and then in the link instead of doing #!page-PAGENAME you'd do #ANCHORNAME

However, this doesn't seem to work

Is it something more like #!page-PAGENAME#ANCHORNAME?

Thanks

Tyrael84 avatar Nov 17 '17 22:11 Tyrael84

The second solution is supposed to work, with page name and anchor

singchan avatar Nov 18 '17 10:11 singchan

Is this solved @Tyrael84 ?

lexoyo avatar Nov 19 '17 14:11 lexoyo

I can't seem to get it to work.

<a name="air-movers"><b><font size="7"><center><font color="#6FA8DC">Air Movers</font></center></font></b></a>

Is on the desired page.

For the link #!page-air-movers#air-movers

Doesn't seem to work.

Tyrael84 avatar Nov 21 '17 21:11 Tyrael84

@lexoyo Any ideas, Alex?

Thanks!

Tyrael84 avatar Nov 24 '17 19:11 Tyrael84

I'm so sorry I will look at this soon If someone knows a little bit of javascript and want to help, please tell me and I will give you instructions

lexoyo avatar Nov 24 '17 19:11 lexoyo

Ok, I finally looked into it It was more complicated than I thought. I think that it used to work but it does not anymore Here is a code you can paste in the "JS editor" of your site and what you did will work

$(function() {
  function checkAnchor() {
    var anchorName = window.location.hash.substr(window.location.hash.lastIndexOf('#') + 1);
    if(anchorName !== '' && anchorName.indexOf('!page-') < 0) {
        // there is an anchor
        var target = $('a[name=' + anchorName + ']').get(0) || $('a[id=' + anchorName + ']').get(0);
        $('html, body').animate({
            scrollTop: $(target).offset().top
        }, 2000);
    }
  }
    
  // this will be executed when the page is loaded
  var current = $('body').pageable('option').currentPage;
  $('body').addClass(current + '-opened');
  $('body').on('pageChanged', function (event, pageName) {
      checkAnchor();
  });
  checkAnchor()
});

Please feel free to ask questions about the code. I used this doc to create it

  • silex doc, see the "Page events" section https://github.com/silexlabs/Silex/issues/200
  • jquery doc https://stackoverflow.com/questions/6677035/jquery-scroll-to-element

lexoyo avatar Dec 03 '17 01:12 lexoyo

Thank-you @lexoyo!

I haven't used silex in a few days and now all of my 522 saved revisions of my site seem to be broken and only showing the header. All of the content is missing and the footer so once I figure out what's going on I'll make sure to let you know if it worked!

Tyrael84 avatar Dec 03 '17 17:12 Tyrael84

I would refresh and try again... And open the page panel and click on the first page

lexoyo avatar Dec 04 '17 06:12 lexoyo

@lexoyo

Well, this is a little terrifying but nothing seems to work. My only guess is that I need to load it up on the real Silex Editor and not the pre-pod one. The only problem is -- dropbox still does not work on the original Silex Editor. :(

Tyrael84 avatar Dec 05 '17 19:12 Tyrael84

please share it with me on dropbox (a.hoyau at im-paris.fr)

lexoyo avatar Dec 06 '17 09:12 lexoyo

Okay bare with me I haven't used DropBox to share files in a while. I created a new folder and I believe I gave you priviledges to view it. Inside are the assets, scripts, css, and the 522th revision of the website (.html).

Right now the 522th revision opens fine on my computer but when I try to load it up on Silex only the header seems to be visible. The footer and all the content seems to be invisible. Unsure why.

Thanks,

Nick.

Tyrael84 avatar Dec 06 '17 23:12 Tyrael84

Hey Alex I'm sure you're busy but figured I'd send you a quick message to see if you have any idea what happened to my site?

When I load up the HTML itself in a browser all the content is still there and working. When I open it up on prepod.silex.me all the content and the footer is gone.

Tyrael84 avatar Dec 18 '17 21:12 Tyrael84

hi @Tyrael84 i finally looked at what you shared, sorry for the long delay, we lack contributors for so many things that i had no time for support...

in you html page "index522.html", i see only content on the page "fire-smoke-damage", and no footer. maybe you deleted the rest by accident?

you can still retrieve a previous version of the site right? did you know you can open a site, copy some elements, then open another site and paste those elements? this could be useful to you

lexoyo avatar Jan 07 '18 13:01 lexoyo

oh and by the way, your site looks great! I would love it even more if it was a bit smaller:

like this: screenshot from 2018-01-07 14-04-19

instead of this:

screenshot from 2018-01-07 14-04-13

lexoyo avatar Jan 07 '18 13:01 lexoyo