Jump to content

Adding to a link


Zephers

Recommended Posts

trying to figure out the proper way to code a change to a link.

 

So the current code is:

	<a href='{$member->url()}' data-searchable>

What I would like is to add this to the end of the url "/&tab=field_core_pfield_31"

 

But thus far every attempt I made has ignored what was added. Appreciate any help you can offer :)

Link to comment
Share on other sites

it didn't work for some reason.

What I am trying to do is change a link from the main profile page to the page that has the About Me as the active tab.

So I want to add to the profile link. When I use this it ignores the added characters and uses the original link.

Basically instead of it linking to:

site/index.php?/profile/383-derrick-mason-gray/

I want it to link to:

site/index.php?/profile/383-derrick-mason-gray/&tab=field_core_pfield_31


using you link it still links to:
site/index.php?/profile/383-derrick-mason-gray/

for some reason.

This is the exact code I am trying to update:

				<a href='{$member->url()}' data-searchable>
					{template="userLink" app="core" group="global" params="$member"}
				</a>

 

Link to comment
Share on other sites

@Zephers

OK.  Must be talking about different part of the site.  This is my link for the profile tab .......r.com/profile/1-admin/?tab=field_core_pfield_1

Are you sure you don't have some other queries before the the "tab="   You need to have a ? right after profile/ to start the query. 

If you have multiple queries you could have ?something=xxx&tab=field_core....

Sorry if I'm pointing out basic URL stuff if I'm not understanding what you are trying to do.

Link to comment
Share on other sites

Might be me not explaining well :p

so on here my profile link is this:

https://invisionpower.com/profile/531843-zephers/

But if I look at my About me tab my profile link becomes:

https://invisionpower.com/profile/531843-zephers/?tab=field_core_pfield_23

So here you see a ?tab. But on my site when I do the same two links my profile and then my profile using the About Me tab as active the two links are:

http://mysite.com/index.php?/profile/1-zeph/

then 

http://mysite.com/index.php?/profile/1-zeph/&tab=field_core_pfield_31

 

Link to comment
Share on other sites

So here is a weird thing. If I change the & to a ? in my link it still works. But if you naturally navigate to the about me page it is the &

So I guess in theory if I have the ? it should still work.

Which brings me back to how do I change the below code to include the /?tab=field_core_pfield_31

<a href='{$member->url()}' data-searchable>
					{template="userLink" app="core" group="global" params="$member"}
				</a>

 

 

Link to comment
Share on other sites

So as was posted by Adriano above, this does what you want if you have $member in the template...

<a href='{$member->url()->setQueryString( 'tab', 'field_core_pfield_17' )}'>link</a>

That generates ...de/index.php?/profile/1-name/&tab=field_core_pfield_17 on my site which works.  

 

Link to comment
Share on other sites

so it doesn't work but I think its because I am putting it into the search template so the coded string is overriding.

 

I think I need to edit the userlink template to make this happen but this one is beyond me:

{{if $member->member_id AND \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'members' ) ) }}<a href='{{if $warningRef}}{$member->url()->setQueryString( 'wr', $warningRef )}{{else}}{$member->url()}{{endif}}' data-ipsHover data-ipsHover-target='{$member->url()->setQueryString( array( 'do' => 'hovercard', 'wr' => $warningRef, 'referrer' => urlencode( \IPS\Request::i()->url() ) ) )}' title="{lang="view_user_profile" sprintf="$member->name"}" class="ipsType_break">{{if $groupFormatting && $member->group['prefix']}}{$member->group['prefix']|raw}{{endif}}{$member->name}{{if $groupFormatting && $member->group['suffix']}}{$member->group['suffix']|raw}{{endif}}</a>{{else}}{{if $groupFormatting && $member->group['prefix']}}{$member->group['prefix']|raw}{{endif}}{$member->name}{{if $groupFormatting && $member->group['suffix']}}{$member->group['suffix']|raw}{{endif}}{{endif}}

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...