1. If you have a site and looking for specific help, please submit a support ticket through Site Owner Dashboard instead of creating a thread in the support forum
    Dismiss Notice

SMF 2.x [Solution] Spoiler not works

Discussion in 'SMF Discussion' started by kj2, Dec 21, 2016.

  1. kj2

    kj2 New Member

    Joined:
    Dec 21, 2016
    Messages:
    1
    Likes Received:
    1
    Note: I speak spanish and understand english, but I not have practice speaking this second, then sorry for the rarely diction on this post (I'm not using Google translate, because it is worse xD).

    I use SMF with Quick Spoiler mod (with some changes made by me), but the spoilers not works :(.

    First, Tapatalk don't support spoiler for SMF:

    https://support.tapatalk.com/threads/support-for-spoiler-tags.18923/#post-99323

    But have support if "spoiler" bbcode is on the post (you can find it on the source code of the tapatalk mod), then we need modify Quick Spoiler for works with this tapatalk mod:

    First edit the file "Sources/Sub-QuickSpoiler.php" and search this:

    Code:
    if (allowedTo('view_spoiler')) {
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">' . (!empty($modSettings['qs_title']) ? $modSettings['qs_title'] : $txt['quick_spoiler']) . '</div><div class="sp-body">',
                    'after'       => '</div></div>',
                    'block_level' => true,
                );
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_equals',
                    'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">$1</div><div class="sp-body">',
                    'after'       => '</div></div>',
                    'block_level' => true,
                );
            }
            else {
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_content',
                    'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                    'block_level' => true,
                );
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_equals_content',
                    'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                    'block_level' => true,
                );
            }
    
    And change it for this:

    Code:
    if (defined('IN_MOBIQUO')){ // Comprobamos si está usando tapatalk
      if (allowedTo('view_spoiler')) {
               $codes[] = array(
                    'tag'         => 'spoiler',
                    'before'      => '[spoiler]',
                    'after'       => '[/spoiler]',
                    'block_level' => true,
                );
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_equals',
                    'before'      => '[spoiler]',
                    'after'       => '[/spoiler]',
                    'block_level' => true,
                );
            }
            else {
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_content',
                    'content'     => '[spoiler]' . $txt['qs_no_spoiler_sorry'] . '[/spoiler]',
                    'block_level' => true,
                );
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_equals_content',
                    'content'     => '[spoiler]' . $txt['qs_no_spoiler_sorry'] . '[/spoiler]',
                    'block_level' => true,
                );
            }
        } else{
            if (allowedTo('view_spoiler')) {
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">' . (!empty($modSettings['qs_title']) ? $modSettings['qs_title'] : $txt['quick_spoiler']) . '</div><div class="sp-body">',
                    'after'       => '</div></div>',
                    'block_level' => true,
                );
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_equals',
                    'before'      => '<div class="sp-wrap"><div class="sp-head sp-open">$1</div><div class="sp-body">',
                    'after'       => '</div></div>',
                    'block_level' => true,
                );
            }
            else {
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_content',
                    'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                    'block_level' => true,
                );
                $codes[] = array(
                    'tag'         => 'spoiler',
                    'type'        => 'unparsed_equals_content',
                    'content'     => '<div class="sp-wrap centertext">' . $txt['qs_no_spoiler_sorry'] . '</div>',
                    'block_level' => true,
                );
            }
        }
    
    But have a problem, the tapatalk only show "spoiler for hidden" on some spoilers, the problem is explained here:

    https://support.tapatalk.com/threads/spoiler-support-using-replace-rule.20549/

    The tapatalk mod only works with "Spolier" (with capital "S"), but this is a error :/, then now we need mod the tapatalk mod for ignore upper/down case for the bbcode:

    Edit the file "mobiquo/mobiquo_common.php" and go to the lines 607 and 608...

    Code:
        $message = str_replace('[spoiler]', "\nSpoiler for Hiden:\n[quote]", $message);
        $message = str_replace('[/spoiler]', '[/quote]', $message);
    
    ...and comment it.

    Code:
        //$message = str_replace('[spoiler]', "\nSpoiler for Hiden:\n[quote]", $message);
        //$message = str_replace('[/spoiler]', '[/quote]', $message);
    
    And now all spoilers works fine :D.
     
    Shambles likes this.
  2. moledj

    moledj Administrator Staff Member

    Joined:
    Oct 29, 2012
    Messages:
    1,939
    Likes Received:
    655
    good finding!
    we will check to make native support to it in our next plugin, but thank you in find this solution and share it with the community

    Mil gracias ;)
     
    Shambles likes this.
  3. Shambles

    Shambles Active Member

    Joined:
    Oct 21, 2010
    Messages:
    123
    Likes Received:
    40
    Excellent post and thanks, @kj2