End of Support for Joomla 3 - Forum closed
[SOLVED] Menu anchor in page
Hello,
I would like to anchor a menu item to a specific module in the page, that is when I click on a menu choice to scroll down in the page to a specific position. I tried to create a menu item as an External URL and set link to #'position of the module' but with no success. It seems like Id element is missing from the html code. What is the correct way of achieving this?
Thank you
I would like to anchor a menu item to a specific module in the page, that is when I click on a menu choice to scroll down in the page to a specific position. I tried to create a menu item as an External URL and set link to #'position of the module' but with no success. It seems like Id element is missing from the html code. What is the correct way of achieving this?
Thank you
by dimrigas
Please Log in or Create an account to join the conversation.
- joomlaplates
- Offline
- Moderator
- Posts: 8807
- Thank you received: 1732
Hi there,
a "scrollto" funtion is not included in this theme.
You have to add your own "anchor" or "id" to the php file > layouts/theme.php where you want to scroll to.
If you are using a custom module you can add an "id" to the module in html modus.
And then you should add this script to the PHP file > layouts/theme.php to use the function from menu item:
And now you have to use a menu item class to make them scroll:
a "scrollto" funtion is not included in this theme.
You have to add your own "anchor" or "id" to the php file > layouts/theme.php where you want to scroll to.
If you are using a custom module you can add an "id" to the module in html modus.
And then you should add this script to the PHP file > layouts/theme.php to use the function from menu item:
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top-70}, 900);
});
});
</script>
Attachment scroll-to-script.jpg not found
And now you have to use a menu item class to make them scroll:
Attachment scroll.jpg not found
Dokumentation:
www.joomlaplates.de/dokumentation.html
www.joomlaplates.de/dokumentation.html
Last Edit:8 years 7 months ago
by joomlaplates
Attachments:
Last edit: 8 years 7 months ago by joomlaplates.
Please Log in or Create an account to join the conversation.
Thanks, it works fine!
Is there a way to control the speed of the scrolling?
Is there a way to control the speed of the scrolling?
by dimrigas
Please Log in or Create an account to join the conversation.
- joomlaplates
- Offline
- Moderator
- Posts: 8807
- Thank you received: 1732
Change the "900" at the script, this is the speed in milli seconds
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top-70}, 900);
});
});
</script>
Dokumentation:
www.joomlaplates.de/dokumentation.html
www.joomlaplates.de/dokumentation.html
Last Edit:8 years 7 months ago
by joomlaplates
Last edit: 8 years 7 months ago by joomlaplates.
The following user(s) said Thank You: dimrigas
Please Log in or Create an account to join the conversation.
Moderators: joomlaplates