Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

@reply linking

DuaneDuane New
edited October 2009 in Vanilla 2.0 - 2.8
what files do i edit to change the url that is pointed to when taggin in disuccion and profile links...


example: @carpediem

Comments

  • Options
    LincLinc Detroit Admin
    I can't tell you what to edit (I haven't gotten to addons/templates yet), but I can tell you where the functionality is based at: class.format.php in the Html method (around line 210).
  • Options
    sorry friend this file seems to be non-existent??
  • Options
    LincLinc Detroit Admin
    You don't have /library/core/class.format.php? Sorry for not specifying directory last night; I was up way too late.
  • Options
    MarkMark Vanilla Staff
    It's the Format::Html method.
  • Options
    is this the area i am looking for?

    if ($Activity->ActivityUserID == $Activity->RegardingUserID) {
    // If the activityuser and regardinguser are the same, use the $Gender Ref as the RegardingName
    $RegardingName = $RegardingProfile = $Gender;
    $RegardingNameP = $RegardingProfileP = $Gender;
    } else if ($Activity->RegardingUserID > 0 && $ProfileUserID != $Activity->RegardingUserID) {
    // If there is a regarding user and we're not looking at his/her profile, link the name.
    $RegardingNameD = urlencode($Activity->RegardingName);
    if (!$IsYou) {
    $RegardingName = Anchor($RegardingName, '/profile/' . $Activity->RegardingUserID . '/' . $RegardingNameD);
    $RegardingNameP = Anchor($RegardingNameP, '/profile/' . $Activity->RegardingUserID . '/' . $RegardingNameD);
    }
    $RegardingWall = Anchor('wall', '/profile/activity/' . $Activity->RegardingUserID . '/' . $RegardingNameD . '#Activity_' . $Activity->ActivityID);
  • Options
    LincLinc Detroit Admin
    If you put it in code tags it retains its formatting so we can read it:
    <code></ code>
    But no, I don't believe that's it; that's from the ActivityHeadline method. It's another ~150 lines past that in the Html method. Search for this text:
    public static function Html($Mixed) and it follows that.
  • Options
    A little off-topic, the @nick association breaks when you use symbols like @nick.name, I think it should only break after whitespace is used.

    Also, what happens when someone changes their nickname? Wouldn't that break all the previous comments your nickname was linked to?
  • Options
    LincLinc Detroit Admin
    edited October 2009
    Yeah, I filed a bug on GitHub for that @ reply period issue, Mike.

    I assume changing your username would break all instances of linking, but then again how often would you do that? It's the same on Twitter. Sure, you can change it, but it's going to screw everyone else up so there's good social pressure against doing it often.
  • Options
    Mike.XIIIMike.XIII New
    edited October 2009
    Yea I'm not too fond of nickname changes myself but I know some people have a thing for changing it ever so often, especially on clan forums for gamers.

    Personally I'm going to make much more use of the comment replies plugin ;)
  • Options
    DuaneDuane New
    edited October 2009
    ah guys im having a bit of trouble changing the urls of this thing, the coding schematic for this is taking some getting used to as im a pretty good amateur

    i am assuming there is

    1. another file or peice of code in another file that produces the hyperlinking
    or
    2. some changes need to be made in the database tables maybe?

    here is where i am

    // Handle @mentions // This one grabs mentions that start at the beginning of $Mixed $Mixed = preg_replace( '/^(@([\d\w_]{1,20}))/si', Anchor('\\1', '/profile/\\2'), $Mixed ); // This one handles all other mentions $Mixed = preg_replace( '/([\s]+)(@([\d\w_]{3,20}))/si', '\\1'.Anchor('\\2', '/profile/\\3'), $Mixed ); return $Formatter->Format($Mixed); } }

    and this makes not one bit of sense LOL
  • Options
    LincLinc Detroit Admin
    edited October 2009
    It's using regular expressions to match the pattern '@username' at the "beginning of $Mixed" ($Mixed being the message's content in this case) and "all other mentions" in the message.

    So look at the first line after preg_replace:
    '/^(@([\d\w_]{1,20}))/si'
    That's a regular expression to match the pattern '@username' (the pattern is between the backslashes; the 's' at the end is actually irrelevant here and the 'i' tells it to be case-insensitive)

    In the next line, the \\1 is what's in the first set of parenthesis (in this case, the entire thing), the \\2 is what's in the second set (just their username without the @). The Anchor method creates a link, linking the text in the first argument to the path in the second argument.

    So in that first preg_replace it's linking your @username to /profile/username. If you want it to link somewhere else, change '/profile/\\2' to your new target, where \\2 is their username.

    You're in for a long day if you're diving into regex: http://us.php.net/manual/en/pcre.pattern.php
Sign In or Register to comment.