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
Switch to threaded view of this topic Create a new topic Submit Reply
SEO url mods question [message #168637] Wed, 12 June 2013 10:48 Go to next message
elmer_fudd is currently offline  elmer_fudd   United States
Messages: 2
Registered: May 2013
Karma: 1
Junior Member
hi,

I am new to fudforum but not new to php. i installed fudforum a few days ago and after it was running it came to my slow brain that i needed more search engine friendly urls. it already has traffic coming to it and i need to hurry and make this change. it is indexed by google and it is a pain to have a bunch of urls indexed and then change them.

anyway, i find myself trying to comb through a ton of code to find what i need. i have basically switched to the path_info template and have everything running like it should. i found this post (i cant use links yet) fudforum.org/forum/index.php?t=msg&goto=162567&&srch=seo+links# msg_162567 and used it as a guide... or am trying to. i changed the code more like this

$_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);

in www/forum/theme/path_info/index.php.

then in index.php i found where /f/ is used like here

'<a href="'.(empty($r[12]) ? './f/'.$r[7].'/'._rsid

and changed it to something like this

'<a href="'.(empty($r[12]) ? './f/'.$r[7].'/'._rsid.$_vcb_forum_name


So far so ok. I switched to thread.php and tried the same thing and it don't work. i can't seem to find the code that generates the thread. For example on this forum (the one we are on now) at the top of the page you are reading it has this

"Home » FUDforum Development » Plugins and Code Hacks"

"Plugins and Code Hacks" is a link. on my forum that link might look something like this "/forum/f/11/" on the index page my forum would show that link like this "/forum/f/11/plugins-and-code-hacks" it clicks and works fine. problem is on the post page i cant find where the code is to make that same link. well i sure thought i found it but not. i hard coded a string onto the end of the url i thought was it but that did not even show up.

maybe i am totally missing something, maybe i been at it too long or maybe i am just a moron. any idea where the code is i need? i plan to "seo" the thread url as well but until i can knock out the other problem there is not much sense.

i know i am rambling, its late, i cant stay awake. i hardly ever ask anyone for help but i am in a bind and don't have time to run all this down. i feel like i am in the twilight zone with this link. i am changing what sure seems the right one but nothing is happening haha. these are the actual code changes in thread.php i am making

<a href="'.(empty($r[12]) ? './f/'.$r[7].'/'._rsid.$_seo_forum_name : $r[12] ) .'">'.$r[10].'</a>';

<td class="RowStyleA wa"><a href="'.(empty($r[12]) ? './f/'.$r[7].'/'._rsid.$_seo_forum_name : $r[12] ) .'" class="big">'.$r[10].'</a>'.($r[11] ? '<br />'.$r[11] : '').$moderators.'</td>

$data .= '&nbsp;&raquo; <a href="./f/'.$fid.'/'._rsid.$_seo_forum_name.'">'.$fn.'</a>';


i am thankful for any and all help
Re: SEO url mods question [message #168639 is a reply to message #168637] Thu, 13 June 2013 11:20 Go to previous messageGo to next message
elmer_fudd is currently offline  elmer_fudd   United States
Messages: 2
Registered: May 2013
Karma: 1
Junior Member
i figured it out myself. later after i finish this job i will post the files some where in case someone else needs them.
Re: SEO url mods question [message #168642 is a reply to message #168639] Fri, 14 June 2013 16:53 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
It would be great it you can clean it up a bit so we can add it to the next release.
Re: SEO url mods question [message #168784 is a reply to message #168642] Thu, 25 July 2013 04:39 Go to previous messageGo to next message
cpreston is currently offline  cpreston   United States
Messages: 160
Registered: July 2012
Location: Oceanside
Karma: 6
Senior Member
Elmer_Fudd

I'd really like to see this final code so i can help Frank work it into the next release.
Re: SEO url mods question [message #168812 is a reply to message #168784] Fri, 26 July 2013 22:52 Go to previous messageGo to next message
cpreston is currently offline  cpreston   United States
Messages: 160
Registered: July 2012
Location: Oceanside
Karma: 6
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>
Re: SEO url mods question [message #168820 is a reply to message #168812] Sat, 27 July 2013 08:34 Go to previous messageGo to next message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Now implemented in core and in the PATH_INFO template set.
For details, see http://sourceforge.net/p/fudforum/code/5627/
Thanks to everyone that worked on this mod.
Re: SEO url mods question [message #168826 is a reply to message #168820] Sat, 27 July 2013 23:53 Go to previous messageGo to next message
cpreston is currently offline  cpreston   United States
Messages: 160
Registered: July 2012
Location: Oceanside
Karma: 6
Senior Member
Awesome!
Re: SEO url mods question [message #168967 is a reply to message #168826] Mon, 12 August 2013 06:22 Go to previous message
naudefj is currently offline  naudefj   
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
The SEO code was split out into a new PATH_INFO_SEO template set (FUDforum 3.0.5 RC2 and higher).
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Email Obfuscation Plugin
Next Topic: User reminder mod
Goto Forum:
  

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

Current Time: Fri Nov 01 00:03:32 GMT 2024

Total time taken to generate the page: 0.02406 seconds