News:

Want to get involved in developing SMF, then why not lend a hand on our github!

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?

Spoogs

#20
What other mods do you have installed, more than likely the target code has been edited by another mod, you can try to manually edit the files if you'd like

Manual Installation of Mods


Actually the errors are there on a fresh install as well.

[Crash_Override]

I considered that as an option so I did a vanilla install on my private server and got the same thing.

PM me if you want to access the test forum and see what I am talking about

seems we both figured that one out

Spoogs

I checked the mod itself it's the number of indentations that are incorrect... for example

Code (find) Select
<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'], '


should be
Code (find) Select
<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'], '

[Crash_Override]

#23
really its that sensitive!?

this makes sense I guess since I use the search option in Dreamweaver to ignore white-space

well I can modify the xml so it works with the default but have had no luck with the core theme

I've attached my modified package that works for now but will leave it up to the developer if they want to continue with it

Cereus

Hello guys! Do you have any update to this MOD?

Hugs!

NekoJonez

I can't delete the moved topic thingies.
Retro video game blogger, writer, actor, podcaster and general amazing dude.

Twitter
My Blog

Kolya

There is another problem with this mod (apart from the fact that you can only delete moved topic notices through the backend):
The moved topic notice (the redirector) is marked unread for anyone but the topic mover. And it is rather difficult to change that state. You cannot go into the topic and marking it as read via checkbox on the topic table doesn't work either for some reason. The only way is to mark ALL read (this can be within a subforum scope).

Which makes me think that a little Javascript redirect inside the topic notice would solve redirection more gracefully.

Kolya

Quote from: Kolya on February 09, 2015, 03:03:12 PM
Which makes me think that a little Javascript redirect inside the topic notice would solve redirection more gracefully.

In Source/MoveTopic.php:
FIND
$txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]'

REPLACE WITH
$txt['movetopic_auto_topic'] => '[iurl]' . $scripturl . '?topic=' . $topic . '.0[/iurl]
     
Redirecting....<script>var mtu = document.getElementsByClassName("bbc_link");setInterval(function(){window.location = mtu[mtu.length-1].innerHTML;},2000);</script>'

Kolya

I have removed my own script (above) from my boards today. It was causing a problem in lists of posts where the redirecting thread appears including its post text and redirection script. The whole listing page was unintentionally redirected in this case. An example of such a list is Posts made by a user and possibly search results.

I have therefore replaced this script with this mod by Arantor which allows to redirect the user as well as setting an expiry date on the redirection topic.

Advertisement: