HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

How can i remove the text "New Discussion" from inside the button ?

I want to remove the text "New Discussion" completely from the button/module "Add new Discussion".

I searched in the file class.newdiscussionmodule.php which renders the button and i tried to use this code:

  public function addButton($url) {
        $this->Buttons[] = ['Url' => $url];
    }

instead of this...

 public function addButton($text, $url) {
        $this->Buttons[] = ['Text' => $text, 'Url' => $url];
    } 

but it doesn't work. Text is still in the button.

One more option could be to create a locale file and use something like that

$Definition['New Discussion'] = '';
but this will remove the text globally :(

What is the solution so i can remove the text only from the button? I could but i don't want to use CSS or js to simply hide the text.
Many thanks

Comments

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    The translation text for the New Discussion is not easy to guess. Looking at the language files might help, you might have to search the for "New Discussion" or you have to ask.

    The translation code for the New Discussion button is AddText, therefore you can add $Definition['AddText'] = ''; to /themes/yourtheme/locale/en.php, which wouldn't be optimal since
    a) it would only be used in english language forums and
    b) any other custom translation might override that

    You can use it in the theme hooks file like that:

        public function base_render_before($sender, $args) {
            Gdn::locale()->setTranslation('AddText', '');
        }
    

    From my perspective this is cleaner since hiding the text is a design decision of the theme and no language issue

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    That is even better:

    base_beforeNewDiscussionButton_handler($sender) {
        Gdn::locale()->setTranslation('AddText', '');
    }
    

    This will only influence the NewDiscussionModule

  • Options

    Thanks for your help @R_J i will try it.

Sign In or Register to comment.