Hi, does anyone know of a way to have SMF default to the top of a topic, and not to the top of the forum webpage when a new topic is posted or when you go into a topic. I can set the page by default to go to the top of the topic board where it shows the topics, but short of retro actively modifying all topics after they are created, when I go into a topic, it goes to the top of the forum webpage. For instance, if I click on this posting after it is created, my scroll bar is at the top of the page. However, I want the page top to be where it would show:
"Simple Machines Community Forum » Customizing SMF » SMF Coding Discussion » Topic: Defaulting to the top of a topic, not the webpage"
Is there a way to set this so it is a default and I don't have to retroactively do it? Our forum is just getting going so I could do it manually now, but as it gets going, it will become too much work to maintain this practice.
Any help would be greatly appreciated. Thanks.
http://wiki.simplemachines.org/smf/Help,_I_keep_going_back_to_the_list_of_topics_when_I_make_a_post
This is great, thanks. However, perhaps I wasn't clear enough. Whether I create a new topic, or click into an existing one, I'm looking for the "top" of my page that is showing to not be the actual top of the page, but instead, the title showing what section of the forum I am in. In the case of this particular post, I would like the "top" of the page that is showing (understanding that there is more above it off of the page) to be:
"Simple Machines Community Forum » Customizing SMF » SMF Coding Discussion » Topic: Defaulting to the top of a topic, not the webpage"
Interesting. What you've just described is not the same as your original post. Nor is it possible to do in SMF properly anyway.
In re-reading my original post, I'm pretty sure I did describe that, but if it is not possible, it's irrelevant either way. Thanks for trying to help. :)
Tiggy00,
I'll give you something to work with but the container id that it indexes may be unique for custom themes.
This example will index the top of a topic in the default theme:
<script type="text/javascript">
window.onload = function () {document.getElementById("forumposts").scrollIntoView(true);}
</script>
If you use a portal you can create an html block and use that code. Hide the title+body of the block and set it to appear on all boards.
Your alternative (if you do not use a portal) is to add that to the appropriate template file.
Which will work just great, right up until the ussr chooses to go to the first unread post, the last post in a topic or to any specific post (since the navigation has links for all of these), which this will break.
http://stackoverflow.com/questions/298503/how-can-you-check-for-a-hash-in-a-url-using-javascript
<script type="text/javascript">
window.onload = function () {
if (!window.location.hash)
document.getElementById("forumposts").scrollIntoView(true);
}
</script>
Thank you all for the advice. I will try and report back on how it works.