Fixed Location in user blurb should open in new tab

JoyFreak

Well-known member
Affected version
2
What template is the location link at? I want to make it open in a new tab rather than redirect the current page to google maps.
 
just search the templates for "misc/location-info".

Here is one place: member_about

HTML:
                    <xf:if is="$user.Profile.location">
                        <dl class="pairs pairs--columns pairs--fixedSmall">
                            <dt>{{ phrase('location') }}</dt>
                            <dd>
                                <a href="{{ link('misc/location-info', '', {'location': $user.Profile.location}) }}" rel="nofollow" target="_blank" class="u-concealed">{$user.Profile.location}</a>
                            </dd>
                        </dl>
                    </xf:if>
as you can see it already opens in a target="_blank"..
 
Yeah I have done exactly what you have said and noticed that it should already open in a new window however it doesn't. It is also the same here on Xenforo, it does not open in new window.

If you click on a member, then click their location, it redirects them on same page.
 
Right, did not notice this till now. There is no target="_blank" in the final source code.

This seems to cause this:

PHP:
        if ($user->Profile->location)
        {
            $location = \XF::escapeString($user->Profile->location);
            $location = '<a href="' . $this->app->router('public')->buildLink('misc/location-info', null, ['location' => $location]) . '" class="u-concealed">' . $location. '</a>';
            $blurbParts[] = \XF::phrase('from_x_location', ['location' => new \XF\PreEscaped($location)])->render();
        }

Method: \XF\Template\Templater->fnUserBlurb()
 
I have reported this thread - let's wait for the staff to answer if this behavior is intended.

If it is important to you, you can try to hack core. Change this line:
PHP:
            $location = '<a href="' . $this->app->router('public')->buildLink('misc/location-info', null, ['location' => $location]) . '" class="u-concealed">' . $location. '</a>';
to
PHP:
            $location = '<a href="' . $this->app->router('public')->buildLink('misc/location-info', null, ['location' => $location]) . '" class="u-concealed" target="_blank">' . $location. '</a>';
This will make the link open in a new window.

File: /src/XF/Template/Templater.php
 
Back
Top Bottom