Latest Post button

Started by kaamaru, August 07, 2009, 04:43:08 PM

Previous topic - Next topic

kaamaru

I want to make a button that goest to the latest post of that topic. (Do not try and tell me a different way to get to last post)

here is what i got so far.
<button onclick="window.location.href=\''.$scripturl . '?topic=' . $context['current_topic'] .'\';">', Latest Post,'</button>'; echo '
I am using smf  2.0 RC1.2

Thank You!  ;D

Arantor

And what happens when you click it?

kaamaru

It just takes me to the topic I want to make it take me to the latest post of that topic.

Arantor

You'll also need to get the id of the last post in that topic.

Assuming you get that, we'll say it's in $id_msg, you would build the link thus:

<button onclick="window.location.href=\''.$scripturl . '?topic=' . $context['current_topic'] .'.msg' . $id_msg . '#msg' . $id_msg . '\';">', Latest Post,'</button>'; echo '

kaamaru

thanks where should i post it in the block of code without causing any errors?
}

echo'

</ul>

<div class="child buttons">';
if($context['user']['is_logged'])

echo '

<button onclick="window.location.href=\''.$scripturl . '?action=post;topic=' . $context['current_topic'] . '.' . $context['start'] . ';num_replies=' . $context['num_replies'].'\';">', $txt['reply'] ,'</button>'; echo '

</div>

<div class="page buttons">

<button onclick="window.location.href=\'', $context['links']['prev'] ,'\';" ', $context['page_info']['current_page']==1 ? 'disabled="disabled"' : '', '>', $txt['iPrev'], '</button>

<button id="pagecount">', $txt['iPage'], ' ', $context['page_info']['current_page'] ,' ', $txt['iOf'] ,' ', ($context['page_info']['num_pages']==0) ? '1' : $context['page_info']['num_pages'] ,'</button>


<button onclick="window.location.href=\'', $context['links']['next'] ,'\';" ', ($context['page_info']['current_page']==$context['page_info']['num_pages']||$context['page_info']['num_pages']==0) ? 'disabled="disabled"' : '', '>', $txt['iNext'], '</button>


</div>
';

}

?>


JBlaze

Jason Clemons
Former Team Member 2009 - 2012

Arantor

Well, you can post it into there but it won't actually work until you populate $id_msg with the id of the last message on the page.

As for where, where would you want it?

kaamaru

#7
I want it under under the previous and next buttons for this theme

I have attached my display.template


kaamaru


[SiNaN]

Try this:

<button onclick="window.location.href=\''.$scripturl . '?topic=' . $context['current_topic'] .';start=new#new\';">', Latest Post,'</button>'; echo '
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: