• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Link depends on option

Matthew Hawley

Well-known member
#1
So...if want a link to change depending on an option how would I do this?

Option = not checked
--- Default link

Option = checked
--- Link changes

Thanks!
 

Chris D

XenForo developer
Staff member
#2
You've not really given enough information, so I'll assume you mean this:

Code:
<xen:if is="{$xenOptions.yourOptionId} == 'some_value'">
    <a href="{xen:link link/default}">Default Link</a>
<xen:else />
     <a href="{xen:link link/changed}">Different link</a>
</xen:if>
 

Matthew Hawley

Well-known member
#3
You've not really given enough information, so I'll assume you mean this:

Code:
<xen:if is="{$xenOptions.yourOptionId} == 'some_value'">
    <a href="{xen:link link/default}">Default Link</a>
<xen:else />
     <a href="{xen:link link/changed}">Different link</a>
</xen:if>
Thanks! What would 'some value' mean? checked?
 

Chris D

XenForo developer
Staff member
#4
It depends on the option type.

If it's just an on/off checkbox you can do this:

Code:
<xen:if is="{$xenOptions.yourOptionId}">
    <a href="{xen:link link/default}">Default Link</a>
<xen:else />
     <a href="{xen:link link/changed}">Different link</a>
</xen:if>
Because an on/off checkbox is either true or false then you don't need to specify the value.

Some options (e.g. radio buttons) have different values some "some_value" could be the ID of the option value.
 

Matthew Hawley

Well-known member
#5
It depends on the option type.

If it's just an on/off checkbox you can do this:

Code:
<xen:if is="{$xenOptions.yourOptionId}">
    <a href="{xen:link link/default}">Default Link</a>
<xen:else />
     <a href="{xen:link link/changed}">Different link</a>
</xen:if>
Because an on/off checkbox is either true or false then you don't need to specify the value.

Some options (e.g. radio buttons) have different values some "some_value" could be the ID of the option value.
It worked. Thank you! :)
 

James

Well-known member
#7

Matthew Hawley

Well-known member
#9
Add another <xen:else />

<xen:if is="">

<xen:elseif is="" />

<xen:else />

</xen:if>
It didn't work. This is the code.

Code:
<xen:if is="{$xenOptions.enableNotableMembers}">
  <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
<xen:else />
  <a href="{xen:link members/list}" class="navLink">{$tabs.members.title}</a>
<xen:else />
<xen:if is="{$xenOptions.enableMemberList}">
<xen:elseif is="{$xenOptions.enableNotableMembers}" />
<a href="{xen:link recent-activity}" class="navLink">{$tabs.members.title}</a>
</xen:else>
</xen:if>
Also when I disable Notable members the link still shows, when i add your code.
 

Chris D

XenForo developer
Staff member
#10
You can't have multiple else statements like that and you can't combine an additional if statement like you have.
 

SneakyDave

Well-known member
#12
Try this:

If NotableMembers is enabled provide that link,
otherwise, if MembersList enabled, provide that link.
otherwise, do some other link.

I think this might work.
Code:
<xen:if is="{$xenOptions.enableNotableMembers}">
  <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
<xen:elseif "{$xenOptions.enableMemberList}" />
  <a href="{xen:link members/list}" class="navLink">{$tabs.members.title}</a>
<xen:else />
  <a href="{xen:link somewhere else}" class="navLink">Somewhere else.</a>
</xen:if>
 

James

Well-known member
#13
Try this:

If NotableMembers is enabled provide that link,
otherwise, if MembersList enabled, provide that link.
otherwise, do some other link.

I think this might work.
Code:
<xen:if is="{$xenOptions.enableNotableMembers}">
  <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
<xen:elseif is="{$xenOptions.enableMemberList}" />
  <a href="{xen:link members/list}" class="navLink">{$tabs.members.title}</a>
<xen:else />
  <a href="{xen:link somewhere else}" class="navLink">Somewhere else.</a>
</xen:if>
That's pretty much it @Matthew Hawley
 
#14
Try this:

If NotableMembers is enabled provide that link,
otherwise, if MembersList enabled, provide that link.
otherwise, do some other link.

I think this might work.
Code:
<xen:if is="{$xenOptions.enableNotableMembers}">
  <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
<xen:elseif "{$xenOptions.enableMemberList}" />
  <a href="{xen:link members/list}" class="navLink">{$tabs.members.title}</a>
<xen:else />
  <a href="{xen:link somewhere else}" class="navLink">Somewhere else.</a>
</xen:if>
Didn't work. If BOTH notable members and member lists is enabled I want it to direct to another link.
 

James

Well-known member
#15
Didn't work. If BOTH notable members and member lists is enabled I want it to direct to another link.
Code:
<xen:if is="{$xenOptions.enableNotableMembers}">
  <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
<xen:elseif is="{$xenOptions.enableMemberList}" />
  <a href="{xen:link members/list}" class="navLink">{$tabs.members.title}</a>
<xen:else />
  <xen:if is="{$xenOptions.enableNotableMembers} && {$xenOptions.enableMemberList}">

      <a href="{xen:link somewhere/else}" class="navLink">Somewhere else.</a>
  </xen:if>
</xen:if>

If notable members: members.href
If member list: members/list
If notable members & member list: somewhere/else.
 
#16
Code:
<xen:if is="{$xenOptions.enableNotableMembers}">
  <a href="{$tabs.members.href}" class="navLink">{$tabs.members.title}</a>
<xen:elseif is="{$xenOptions.enableMemberList}" />
  <a href="{xen:link members/list}" class="navLink">{$tabs.members.title}</a>
<xen:else />
  <xen:if is="{$xenOptions.enableNotableMembers} && {$xenOptions.enableMemberList}">

      <a href="{xen:link somewhere/else}" class="navLink">Somewhere else.</a>
  </xen:if>
</xen:if>

If notable members: members.href
If member list: members/list
If notable members & member list: somewhere/else.
Didn't work.