News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

[Outdated] Redirect Moved Topics

Started by SleePy, June 24, 2008, 10:56:10 PM

Previous topic - Next topic

SleePy

Link to the mod

This customization will make all future moved topic notices redirect automatically to the topics new location.
The message is still posted for the redirect topic incase you ever want to remove this customization or in process of an upgrade.

There are some minimal changes to the MessageIndex.template.php that are not needed but do make it look a bit nicer for your moved topic links by removing the useless junk such as replies, views, etc.

SMF 2.1 does this by default and this is no longer required
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Nathaniel

Thanks for the nice modification SleePy.

Installed perfectly (on a forum with 15+ mods) and works very well! :D
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

ディン1031

Is it possible to make a Version for SMF 1.1.x?

Bye
DIN1031
Support only via MOD Thread! NO PM Support!
My Forum: ayu][kult Forum
My Mods: My Small Mod Collection
My Parser: DIN1031's ModParser
Current Info: More away the next days, because i've to much work to do :x

SleePy

Not really.
This version taps into the approved and id_previous_topic columns that only exist in 2.0. Which is the reason it is able to be done so easily :)

To make a 1.1 version we would have copy the approved and id_previous_topic from 2.0 smf_topics table and use the same thing in 1.1 so upgrading to 2.0 in the future would work.

Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

aldo

Awesome! I always saw little point in the move topic posts themselves when they should have been redirected to the new ones in the first place :P Thanks!

Rocks-HD

how

it's the gretest mod and work very well in smf 2.0 beta 3.1 public

thanks

Rocks-HD

I have a problem

when I move a topic I can't delete the topic of the redirect.

I don't know what to do!

Nathaniel

Okay, this mod has an error, this edit from the 'Redirect_Moved_Topics-20b3p.xml' file returns some errors.
      <operation>
         <search position="replace"><![CDATA[               'href' => $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new',
               'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . ($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'
]]></search>
         <add><![CDATA[               'href' => $scripturl . '?topic=' . ($row['approved'] == 2 && !empty($row['id_previous_topic']) ? $row['id_previous_topic'] : $row['id_topic']) . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')),
               'link' => '<a href="' . $scripturl . '?topic=' . ($row['approved'] == 2 && !empty($row['id_previous_topic']) ? $row['id_previous_topic'] : $row['id_topic']) . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')) . '" ' . ($row['num_replies'] == 0 ? '' : 'rel="nofollow"') . '>' . $row['last_subject'] . '</a>'
]]></add>
      </operation>


The errors only seem to occur for guests, and they concern the lack of a $context['pageindex_multiplier'] value:
Quote
http://www.verbtest.com/index.php?board=3.0;sort=last_post
2: Division by zero
File: /******/Sources/MessageIndex.php
Line: 552
Quote
http://www.verbtest.com/index.php?board=3.0;sort=last_post
8: Undefined index: pageindex_multiplier
File: /*****/Sources/MessageIndex.php
Line: 552

Line 552 is this:
'href' => $scripturl . '?topic=' . ($row['approved'] == 2 && !empty($row['id_previous_topic']) ? $row['id_previous_topic'] : $row['id_topic']) . ($user_info['is_guest'] ? ('.' . (!empty($options['view_newest_first']) ? 0 : ((int) (($row['num_replies']) / $context['pageindex_multiplier'])) * $context['pageindex_multiplier']) . '#msg' . $row['id_last_msg']) : (($row['num_replies'] == 0 ? '.0' : '.msg' . $row['id_last_msg']) . '#new')),

Have a look at this thread for reference:
http://www.simplemachines.org/community/index.php?topic=253916.new#new
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Rocks-HD

thanks man

it's work very well

dannbass

@Sleepy, that package manager says that the file is corrupted, could you re-upload it again?

SleePy

I repackaged the file and reuploaded it.  Try again :)
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

dannbass

#11
Awesome! thank you!! installed perfectly, and looks very nice!

aw06

Quote from: Rocks-HD on July 31, 2008, 01:13:48 PM
I have a problem

when I move a topic I can't delete the topic of the redirect.

I don't know what to do!

Go to Forum Maintenance>Remove Old Posts>Moved topic notices.
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

frozenas

Hi. How can i replace that:

  'href' => $scripturl . '?topic=' . $row['id_topic'] . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0">' . $row['first_subject'] . '</a>' 

to that code:

  'href' => $scripturl . '?topic=' . ($row['approved'] == 2 && !empty($row['id_previous_topic']) ? $row['id_previous_topic'] : $row['id_topic']) . '.0', 'link' => '<a href="' . $scripturl . '?topic=' . ($row['approved'] == 2 && !empty($row['id_previous_topic']) ? $row['id_previous_topic'] : $row['id_topic']) . '.0">' . $row['first_subject'] . '</a>' 

when my template have this code:

'href' => $scripturl . '?topic=' . ($row['approved'] == 2 && !empty($row['id_previous_topic']) ? $row['id_previous_topic'] : $row['id_topic']) . '.0',
'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0"'  . $row['nice_tooltip_first_msg'] . ' >' . $row['first_subject'] . '</a>'
?

Joker™

great mod SleePy ;D , specially for a guy like me who's mods are very lazy , they always leave tails of posts on boards .
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

SleePy

frozenas,

It looks like the code was already applied to that section of code.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Rain Forest


[Crash_Override]

Is this mod still in development?

If it is I would like to brink to attention that although it says it is compatible with version 2.0 I get at least 5 errors when trying to install it on a regular SMF board

Spoogs

What are the errors you get?

[Crash_Override]

In ./Sources/Subs-Post.php

Find
'id_poll' => 'int', 'unapproved_posts' => 'int', 'approved' => 'int',


Replace


'id_poll' => 'int', 'unapproved_posts' => 'int', 'approved' => 'int',
                // Add this in for Moved Redirction Topics.
'id_previous_topic' => 'int',





Find

$topicOptions['poll'] === null ? 0 : $topicOptions['poll'], $msgOptions['approved'] ? 0 : 1, $msgOptions['approved'],


Replace

$topicOptions['poll'] === null ? 0 : $topicOptions['poll'], $msgOptions['approved'] ? 0 : 1, $msgOptions['approved'],
                // Tell it where to send the Moved Redirect Topic, maybe.
!empty($topicOptions['id_previous_topic']) ? $topicOptions['id_previous_topic'] : 0,


Then in ./Themes/default/MessageIndex.template.php

Find

<img src="', $settings['images_url'], '/topic/', $topic['class'], '.gif" alt="" />


Replace

', !$topic['is_moved_redirect'] ? '<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />' : '' ,'





Find

<img src="', $topic['first_post']['icon_url'], '" alt="" />


Replace

', !$topic['is_moved_redirect'] ? '<img src="' . $topic['first_post']['icon_url'] . '" alt="" />' : '', '





Find

// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'])


Replace

// Is this topic new? (assuming they are logged in!)
if ($topic['new'] && $context['user']['is_logged'] && !$topic['is_moved_redirect'])





Find

', $topic['replies'], ' ', $txt['replies'], '


Replace

', $topic['is_moved_redirect'] ? '--' : $topic['replies'] . ' ' . $txt['replies'], '





Find

', $topic['views'], ' ', $txt['views'], '


Replace

', $topic['is_moved_redirect'] ? '--' : $topic['views'] . ' ' . $txt['views'], '





Find

<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt['last_post'], '" title="', $txt['last_post'], '" /></a>
', $topic['last_post']['time'], '<br />
', $txt['by'], ' ', $topic['last_post']['member']['link'], '


Replace

', $topic['is_moved_redirect'] ? '--' : '<a href="' . $topic['last_post']['href'] . '"><img src="' . $settings['images_url'] . '/icons/last_post.gif" alt="' . $txt['last_post'] . '" title="' . $txt['last_post'] . '" /></a>
' . $topic['last_post']['time'] . '<br />
' . $txt['by'] . ' ' . $topic['last_post']['member']['link'], '


Now the weird thing is I can find all of those code segments in the corresponding files but the package won't install no matter what.  Does this mean I have to do it manually?

Advertisement: