1

So,

I am creating a (nearly) single page website. It has a one-page homepage, plus a contact page and a ToS page which are standalone pages. The menu links on the homepage are like '#intro', '#whatwedo', etc, but on the standalone pages I need the links to be 'site.com/#intro' so that it links them to the anchor on the homepage.

How is the best way to achieve this without having two menu blocks?

Cheers

2 Answers 2

1

Use the single page site module, this has all the functionality you need to get this working. https://www.drupal.org/project/single_page_site

1
  • Thanks, but I think you have misunderstood me! The website's homepage is in a single page format, with lots of anchored sections, and the links in the menu link to the anchors of the page. But, I'm trying to find a way to get the links in the same menu to link back to the anchors on the homepage when the user has browsed to another page. E.g. when user goes to Contact page, if they click 'About' in the menu, I want them to go back to /home/#about, not /contact#about Do you see what I mean?
    – caustic
    Commented Mar 10, 2015 at 4:31
0

Wow, I can't read.

Alright, well you can use a hook_MENU_ALTER and just edit the links if the current path is not the front page.

2
  • Thanks for the suggestion! How would I accomplish this; what might the code look like? How can I check if link is not front page, and then prepend the base URL to the link if user is not on homepage?
    – caustic
    Commented Mar 10, 2015 at 11:27
  • ACTUALLY... @KyleTaylored ... I've set up the menu links like this: (website.com/#about) through the Drupal menu admin, but how can I use hook_menu_alter to REMOVE everything before the # in the link? So, on other pages the link would be: website.com/#about, but on the homepage it would just be #about ? Thanks in advance :)
    – caustic
    Commented Mar 10, 2015 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.