Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

I can't get PremHide to work

13

Comments

  • @Shadowdare said:
    shootingtars, would you post a screenshot and does it only turn posts with the prem tags into what you are describing?

    Actually when you're logged in, everything is fine and the text looks normal. But if you're not logged in, everything is a run on sentence and it looks like this:

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    a link to the installation wold help a lot

  • @vrijvlinder said:
    a link to the installation wold help a lot

    What do u mean a link to the installation?

  • peregrineperegrine MVP
    edited July 2013

    @shootingtars said

    a link to the installation wold help a lot

    What do u mean a link to the installation?

    if I must speak in plain english- that could be translated to Post a link to your site so we can see it.

    also answer part two of shadowdare's question.

    also what kind of formatting are you using markdown, html, etc.

    also what editor are you using buttonbar, cleditorm etc ?

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @peregrine said:
    shootingtars said
    also what editor are you using buttonbar, cleditorm etc ?

    Im using BBCODE. I swiched it to Markdown and HTML..both didnt work.
    Im not using any editor.

  • follow these steps and it might be easier to determine.

    • try "Html" as the format code in config.php

    • and then post a new discussion with premium content and see if it works.

    • both signed in and not signed in for the only newly created discussions.

    • refresh the browser - so you are not looking at the effects of the postcontroller (what you see immediately after posting).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • peregrineperegrine MVP
    edited July 2013

    I believe I see the problem

    $body = $Sender->EventArguments['Object']->Body;
    

    at this point Body is not Formatted.

    hence the newly created formatbody is not formatted, just the replacement is made.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • AdrianAdrian Wandering Spirit Montreal MVP

    @peregrine thanks for stepping in. It's weird I don't get notification emails on comments about my addons. I'm not near a desktop computer so appreciate you help out the user. I hope to be online later to troubleshoot ...

  • peregrineperegrine MVP
    edited July 2013

    people should mention you if they want you. @adriansonline . seems like the logical thing if you want the plugin author.

    but I think you need to figure out how to process formatbody rather than body if you want the non-signed in results to be formatted properly.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • AdrianAdrian Wandering Spirit Montreal MVP

    That's true @peregrine. It's hard to wait by the computer to see if you don't get mentioned. I'll try your suggestion when I get home ;)

  • peregrineperegrine MVP
    edited July 2013

    I know x00 suggested using /1 and you don't want to use brackets
    but this is functional with brackets [prem] [/prem] in markdown
    and seems to format correctly logged in and not logged in
    I also made a change in login string. i didn't test with buttonbar or html and only tested in 2.0.18.8

        public function DiscussionController_AfterCommentFormat_Handler($Sender) {
             $Session = Gdn::Session();
            $pattern = '#\[prem\](.*?)\[\/prem\]#si';
            $body = $Sender->EventArguments['Object']->FormatBody;
            if (($Session->IsValid())) {
            $pattern = '#\[.?prem\]#si';
            $context = preg_replace($pattern, "", $body); 
            }  else {
             $LoginStr = "<p>".T("Please")." <a href='".Url('/').SignInUrl($this->SelfUrl)."'>".T("Login ")."</a>".T("To See Premium Content")."</p>";
             $context = preg_replace($pattern, $LoginStr, $body);
            }  
            $Sender->EventArguments['Object']->FormatBody = $context;
    
        }
    

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • anybody who wants to make it more elegant :) be my guest.

    function before beauty :).

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • AdrianAdrian Wandering Spirit Montreal MVP

    Hi @peregrine looks like it works to me. The reason I was not using square brackets was to keep backwards compatibility for others who had a similar function before....But alas, I will succumb and change it. I want it to function more than I care for beauty :) I have updated the addon.

  • @peregrine said:
    anybody who wants to make it more elegant :) be my guest.

    function before beauty :).

    looks fine

    you could change to

    $pattern = '#\[\/?prem\]#si';

    grep is your friend.

  • Thanks for the hard work guys! It's working now! THANK YOU SO MUCH!!

  • edited July 2013

    thanks

  • Can I change the code [prem] to [hide]? I try to do it myself by changing it in default.php but it doesnt seem to work..

  • AdrianAdrian Wandering Spirit Montreal MVP

    @shootingstars, if you change all instances of Prem to Hide is should work

  • Weird... I cant use the tag [hide] anymore. I guess I had the spoilers pluggin enabled before and changed the tag to [hide] . when i removed it, i still cant use the word [hide]. so i had to use another word and it works.

  • now it doesnt work on mobile. any way to fix this?

Sign In or Register to comment.