Link depends on option

Matthew Hawley

Well-known member
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!
 
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>
 
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?
 
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 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! :)
 
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.
 
You can't have multiple else statements like that and you can't combine an additional if statement like you have.
 
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>
 
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
 
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.
 
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.
 
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.
 
Could you provide some more information? Perhaps debug the code yourself? Which ones work and which ones don't?
 
Looks to me like James solution should work. Does your version look just like it?

never mind. Are you missing an
</xen:if>
somewhere?
 
Back
Top Bottom