Results 1 to 7 of 7

Rewrite or filter title characters??

This is a discussion on Rewrite or filter title characters?? within the General Discussion forums, part of the vBSEO SEO Plugin category; Is there a rewrite or some way to filter special characters from thread titles? If there is already a vBulletin ...

  1. #1
    Member
    Real Name
    Ken
    Join Date
    Dec 2006
    Posts
    45
    Liked
    0 times

    Rewrite or filter title characters??

    Is there a rewrite or some way to filter special characters from thread titles? If there is already a vBulletin control for this I apologize, but I've yet to locate it.

    Basically what I'd like to do is delete any non a-z characters that get typed into thread titles. vBSEO already rewrites this in the URL but not the actual title. Example; if someone titles their thread "widget!?" I'd like to rewrite this as "widget". This is mostly for asthetics, since it drives me crazy to see all these characters appear in my navbar message.

    Case in point, I purposely typed "??" after the title for this thread. The welcome message above says "This is a discussion on Rewrite or filter title characters?? within the General Discussion forums". To me seeing those two "??" mid sentence looks terrible.

    Also while I don't know that much about SEO, I would think that both words (widget!? and widget) could be indexed differently. Regardless, I'd just rather not see non-alpha characters appear mid-sentence in a description.

  2. #2
    vBSEO Staff Ace Shattock's Avatar
    Real Name
    Ace Shattock
    Join Date
    Jul 2005
    Location
    Auckland, New Zealand, New Zealand
    Posts
    3,998
    Liked
    11 times
    Hi Ken,

    I'm fairly certain that the Search Engines view a word the same, whether it is alone, or has punctuation before or after it.

  3. #3
    Member
    Real Name
    Ken
    Join Date
    Dec 2006
    Posts
    45
    Liked
    0 times
    Thanks, thats reassurring but I would still like to find out how to do this. Even if for nothing more than to figure it out. I started looking into writting a condition or something similar but yet to find the answer.

  4. #4
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    You can manually apply title modifications in includes/class_dm_threadpost.php file.
    FIND:
    PHP Code:
            $title preg_replace('/&#(0*32|x0*20);/'' '$title); 
    and add below your characters filtering code, like:
    PHP Code:
            $title preg_replace('/[\?\!]/'' '$title); 
    (that will remove ? and ! characters)
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  5. #5
    Member
    Real Name
    Ken
    Join Date
    Dec 2006
    Posts
    45
    Liked
    0 times
    Perfect! I took this a step further by adding all the characters I don't want to see or to be replaced by in all post titles. Here it is.

    Found:
    Code:
    // replace html-encoded spaces with actual spaces
    $title = preg_replace('/&#(0*32|x0*20);/', ' ', $title);
    Added below it:
    Code:
    // replace special characters with actual spaces
    $title = preg_replace('/[\?\!\#\$\%\^\*\~\|\:\;\...]/', ' ', $title);
    // replace special characters with...
    $title = preg_replace('/[\@]/', ' at ', $title);
    $title = preg_replace('/[\+]/', ' plus ', $title);
    $title = preg_replace('/[\=]/', ' equals ', $title);
    $title = preg_replace('/[\&]/', ' and ', $title);
    Thanks Oleg

  6. #6
    vBSEO Staff Oleg Ignatiuk's Avatar
    Real Name
    Oleg Ignatiuk
    Join Date
    Jun 2005
    Location
    Belarus
    Posts
    25,689
    Liked
    157 times
    Instead of last 4 lines you can use:
    PHP Code:
    $title str_replace(
    array(
    '@''+''=''^'),
    array(
    ' at '' plus '' equals '' and '),
    $title); 
    Oleg Ignatiuk / Crawlability Inc.
    vBSEO 3.6.0 GOLD Released!
    Unveiling the NEW vBSEO Sitemap Generator 3.0. - available NOW for vBSEO Customers!


  7. #7
    Member
    Real Name
    Ken
    Join Date
    Dec 2006
    Posts
    45
    Liked
    0 times
    Yeah, actually thought of writing it that way afterward.

    Thanks again!

Similar Threads

  1. Syntax for Custom Rewrite Rules
    By Joe Ward in forum Custom Rewrite Rules
    Replies: 33
    Last Post: 02-10-2011, 09:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •