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

XF 1.4 How do i make it so Spoiler only works for registered guests?

Discussion in 'Styling and Customization Questions' started by Martyn, Mar 24, 2015.

  1. Martyn

    Martyn Active Member

    Been trying to make it so that Spoil bbcode will only work for registered guest, but it seems that anyone can click it..

    Anyone know how to tweak this?

    many thanks
     
  2. Liam W

    Liam W Well-Known Member

    If you edit the bbcode_spoiler_tag template to this:

    find:
    HTML:
    <div class="ToggleTriggerAnchor bbCodeSpoilerContainer">
       <button class="button bbCodeSpoilerButton ToggleTrigger Tooltip JsOnly"
         title="{xen:phrase click_to_reveal_spoiler}"
         data-target="> .SpoilerTarget"><span>{xen:phrase spoiler}{xen:if $titleHtml, ': <span class="SpoilerTitle">{xen:raw $titleHtml}</span>'}</span></button>
       <div class="SpoilerTarget bbCodeSpoilerText">{xen:raw $content}</div>
    </div>
    
    replace:

    HTML:
    <xen:if is="{$visitor.user_id}">
    <div class="ToggleTriggerAnchor bbCodeSpoilerContainer">
       <button class="button bbCodeSpoilerButton ToggleTrigger Tooltip JsOnly"
         title="{xen:phrase click_to_reveal_spoiler}"
         data-target="> .SpoilerTarget"><span>{xen:phrase spoiler}{xen:if $titleHtml, ': <span class="SpoilerTitle">{xen:raw $titleHtml}</span>'}</span></button>
       <div class="SpoilerTarget bbCodeSpoilerText">{xen:raw $content}</div>
    </div>
    <xen:else />
    <button class="button" title="{xen:phrase click_to_reveal_spoiler}"><span>You need to register to view spoilers!</span></button>
    </xen:if>
    
    It should work :)
     
    Martyn likes this.
  3. Martyn

    Martyn Active Member

    Brilliant Liam, will that show the Spoiler, but not allow them to open it? :)

    edit: yep just seen the bottom of that code, thank you very much @Liam W
     
    Liam W likes this.
  4. Martyn

    Martyn Active Member

    @Liam W anyway to make the button take them to the register page? :)

    Currently it takes them to the url /inline-mod/post/switch
     
  5. Liam W

    Liam W Well-Known Member

    Replace the button with a link:

    Code:
    <a href="{xen:link register}" class="button"><span>You need to register to view spoilers!</span></a>
    
     
    Martyn likes this.
  6. Martyn

    Martyn Active Member

    one last thing @Liam W anyway to make it say the spoiler title?

    E.g rather then you need to register to view spoiler, could I make it say you need to register to view Title, an if no title then spoiler?

    Actually wondering now if I should have made another BBcode for this lol
     
  7. Martyn

    Martyn Active Member

    actually would it be easy to make a new bbcode similar to spoiler? just to hide a download link from guests? that way I could keep the spoiler tag in tact
     
  8. Liam W

    Liam W Well-Known Member

    That is possible, but it would have to have a php callback to have it render as a template (if the custom bbcode system is used).

    Liam
     
  9. Martyn

    Martyn Active Member

    could it not just callback to spoiler? or isn't that possible?
     
  10. Liam W

    Liam W Well-Known Member

    Then the new bbcode would be exactly the same as the spoiler code - basically a duplicate.

    Liam
     
  11. Martyn

    Martyn Active Member

    Would the template be the same? would everything have spoiler in it or can I customize that in the template settings?

    Maybe ill have to keep it like this with the default spoiler just so guests can't view it,

    Thanks for your time an help @Liam W
     
  12. Martyn

    Martyn Active Member

    @Liam W anyway to still hide this from users with non verified email accounts?
     

Share This Page