FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Plugins and Code Hacks » SEO url mods question
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: SEO url mods question [message #168812 is a reply to message #168784] Fri, 26 July 2013 22:52 Go to previous messageGo to previous message
cpreston is currently offline  cpreston   United States
Messages: 160
Registered: July 2012
Location: Oceanside
Karma:
Senior Member
I think I figured this out. Or at least I figured out what changes need to be made to index.php and thread.php. I only know how to make it in the "already built" source in /forum/theme/<themename>/. I'm hoping someone else can roll these changes into the built in path_info template set.

Note that I actually appended the forum title and topic title immediately to the forum/topic id number. This is slightly different than what the original poster did, but I like putting it right next to the id number better. That also separates it from anything that might go after the "/" (like message id).

I built my default theme based on the path_info template set. Then I edited the following files.

1. Edit ~/forum/theme/<themename>/index.php

2. Find the following line of code
/* Compact category view (ignore when expanded). */


3. Insert the following before that line:

$_seo_forum_name = $r[10];
$_seo_forum_name = strtolower($_seo_forum_name);
$_seo_forum_name = strip_tags($_seo_forum_name);
$_seo_forum_name = html_entity_decode($_seo_forum_name);
$_seo_forum_name = urldecode($_seo_forum_name);
$_seo_forum_name = trim($_seo_forum_name);
$_seo_forum_name = preg_replace('/ +/', ' ', $_seo_forum_name);
$_seo_forum_name = preg_replace('/[^A-Za-z0-9\s]/', '', $_seo_forum_name);
$_seo_forum_name = preg_replace('/ /', '-', $_seo_forum_name);


4. Find the following line of code:
<a href="'.(empty($r[12]) ? 'index.php/f/'.$r[7].'/'._rsid : $r[12] )  .'">'.$r[10].'</a>';


5. Change it to the following (Insert "'-'.$_seo_forum_name." after the "$r[7]."):
<a href="'.(empty($r[12]) ? 'index.php/f/'.$r[7].'-'.$_seo_forum_name.'/'._rsid : $r[12] )  .'">'.$r[10].'</a>';


6. Find the following line of code:
<td class="RowStyleA wa"><a href="'.(empty($r[12]) ? 'index.php/f/'.$r[7].'/'._rsid : $r[12] )  .'" class="big">'.$r[10].'</a>'.($r[11] ? '<br />'.$r[11] : '').$moderators.'</td>


7. Change it to the following (Insert "'-'.$_seo_forum_name." after the "$r[7]."):
<td class="RowStyleA wa"><a href="'.(empty($r[12]) ? 'index.php/f/'.$r[7].'-'.$_seo_forum_name.'/'._rsid : $r[12] )  .'" class="big">'.$r[10].'</a>'.($r[11] ? '<br />'.$r[11] : '').$moderators.'</td>


8. Edit ~/forum/theme/<themename>/thread.php

9. Find the following section of code:

$thread_read_status = $first_unread_msg_link = '';
if (_uid && $usr->last_read < $r[10] && $r[10] > $r[20]) {


10. Insert the following before that code:

$_seo_topic_name = $r[2];
$_seo_topic_name = strtolower($_seo_topic_name);
$_seo_topic_name = strip_tags($_seo_topic_name);
$_seo_topic_name = html_entity_decode($_seo_topic_name);
$_seo_topic_name = urldecode($_seo_topic_name);
$_seo_topic_name = trim($_seo_topic_name);
$_seo_topic_name = preg_replace('/ +/', ' ', $_seo_topic_name);
$_seo_topic_name = preg_replace('/[^A-Za-z0-9\s]/', '', $_seo_topic_name);
$_seo_topic_name = preg_replace('/ /', '-', $_seo_topic_name);


11. Find the following line of code:

$first_unread_msg_link = '<a href="index.php/t/'.$r[13].'/0/unread/'._rsid.'"><img src="theme/default/images/newposts.gif" title="Go to the first unread message in this topic" alt="" /></a>&nbsp;';


12. Change it to the following (Insert "'-'.$_seo_topic_name." after the "$r[13]."):
$first_unread_msg_link = '<a href="index.php/t/'.$r[13].'-'.$_seo_topic_name.'/0/unread/'._rsid.'"><img src="theme/default/images/newposts.gif" title="Go to the first unread message in this topic" alt="" /></a>&nbsp;';


13. Find the following line of code:

<td class="RowStyleA">'.(($r[18] > 1) ? ($r[18] & 4 ? '<span class="StClr">sticky:&nbsp;</span>' : '<span class="AnClr">Announcement:&nbsp;</span>' )  : '' ) .$first_unread_msg_link.($r[1] ? 'Poll:&nbsp;' : '' ) .($r[0] ? '<img src="theme/default/images/attachment.gif" alt="" />' : '' ) .'<a class="big" href="index.php/t/'.$r[13].'/'._rsid.'">'.$r[2].'</a>'.($r[22] ? '<br /><span class="small">'.$r[22].'</span>' : '' )  .' '.((($FUD_OPT_2 & 4096) && $r[17]) ? ($MOD || $mo == 8224 ? '<a href="javascript://" onclick="window_open(\''.$GLOBALS['WWW_ROOT'].'index.php?t=ratingtrack&amp;'._rsid.'&amp;th='.$r[13].'\', \'th_rating_track\', 300, 400);">' : '' ) .'<img src="theme/default/images/'.$r[17].'stars.gif" title="'.$r[17].' from '.convertPlural($r[21], array(''.$r[21].' vote',''.$r[21].' votes')).'" alt="" />'.($MOD || $mo == 8224 ? '</a>' : '' ) : '' ) .' '.$mini_thread_pager.' <div class="TopBy">By: '.($r[5] ? '<a href="index.php/u/'.$r[6].'/'._rsid.'">'.$r[5].'</a>' : $GLOBALS['ANON_NICK'].'' ) .' on <span class="DateText">'.strftime('%a, %d %B %Y', $r[4]).'</span></div>'.$admin_control_row.'</td>


14. Change it to the following (Insert "'-'.$_seo_topic_name." after the "$r[13]."):
<td class="RowStyleA">'.(($r[18] > 1) ? ($r[18] & 4 ? '<span class="StClr">sticky:&nbsp;</span>' : '<span class="AnClr">Announcement:&nbsp;</span>' )  : '' ) .$first_unread_msg_link.($r[1] ? 'Poll:&nbsp;' : '' ) .($r[0] ? '<img src="theme/default/images/attachment.gif" alt="" />' : '' ) .'<a class="big" href="index.php/t/'.$r[13].'-'.$_seo_topic_name.'/'._rsid.'">'.$r[2].'</a>'.($r[22] ? '<br /><span class="small">'.$r[22].'</span>' : '' )  .' '.((($FUD_OPT_2 & 4096) && $r[17]) ? ($MOD || $mo == 8224 ? '<a href="javascript://" onclick="window_open(\''.$GLOBALS['WWW_ROOT'].'index.php?t=ratingtrack&amp;'._rsid.'&amp;th='.$r[13].'\', \'th_rating_track\', 300, 400);">' : '' ) .'<img src="theme/default/images/'.$r[17].'stars.gif" title="'.$r[17].' from '.convertPlural($r[21], array(''.$r[21].' vote',''.$r[21].' votes')).'" alt="" />'.($MOD || $mo == 8224 ? '</a>' : '' ) : '' ) .' '.$mini_thread_pager.' <div class="TopBy">By: '.($r[5] ? '<a href="index.php/u/'.$r[6].'/'._rsid.'">'.$r[5].'</a>' : $GLOBALS['ANON_NICK'].'' ) .' on <span class="DateText">'.strftime('%a, %d %B %Y', $r[4]).'</span></div>'.$admin_control_row.'</td>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Email Obfuscation Plugin
Next Topic: User reminder mod
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Dec 05 02:25:24 GMT 2024

Total time taken to generate the page: 0.04003 seconds