SEO url mods question [message #168637] |
Wed, 12 June 2013 10:48 |
|
elmer_fudd
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 .= ' » <a href="./f/'.$fid.'/'._rsid.$_seo_forum_name.'">'.$fn.'</a>';
i am thankful for any and all help
|
|
|
|
|
|
Re: SEO url mods question [message #168812 is a reply to message #168784] |
Fri, 26 July 2013 22:52 |
|
cpreston
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> ';
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> ';
13. Find the following line of code:
<td class="RowStyleA">'.(($r[18] > 1) ? ($r[18] & 4 ? '<span class="StClr">sticky: </span>' : '<span class="AnClr">Announcement: </span>' ) : '' ) .$first_unread_msg_link.($r[1] ? 'Poll: ' : '' ) .($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&'._rsid.'&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: </span>' : '<span class="AnClr">Announcement: </span>' ) : '' ) .$first_unread_msg_link.($r[1] ? 'Poll: ' : '' ) .($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&'._rsid.'&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>
|
|
|
|
|
|