2

I creating a feature on my SharePoint site where users can create a list item and then comment on it. After the item is created, a calendar entry is also created. The purpose is to cut down on email traffic between team members and keep it on SharePoint instead.

I have been able to accomplish everything so far, except for changing the "new discussion" link text that allows you to create a new discussion (in my case, a list item). I have seen various methods that use javascript or SharePoint Designer 2010 and opening the page in Design View. I have tried SPD2010, but it is incompatible with my page. I would like to avoid using javascript in order to allow slightly easier maintenance if needed in the future.

I have access to SharePoint Designer 2013. Can anyone help me change the "new discussion" text? Thank you.

1

Preface, tried this on SP2010 not 2013:

Something you can try is creating a new content type that inherits from the Discussion content type. Then in your discussion list, go to the list settings and add your newly created content type and delete the discussion content type.

When selecting to create a new item, the content type name will be present. Then you'd just need to put the allitems view into edit mode and change the web part options to no tool bar.

1

Your problem can be solved via JsLink as well as overriding methods from the sp.ui.discussions.js file under the layouts hive. And about maintenability, this file is easy to maintain because you only change the text of the variable "NewDiscussionTitle"

var newDiscussionTitle = "Your Custom New Text ";
SP.UI.Discussions.HeaderBehavior.prototype.render = function (a) {
    ULS06I:;
    if (!SP.UI.Discussions.Helpers.isAnonymousAccess(this.context)) {
        var b = this.getNewPostUrl();
        a.addCommunitiesCssClass("heroLinkContainer");
        a.renderBeginTag("div");
        a.addAttribute("id", this.$1F_0);
        a.addAttribute("href", b);
        a.addCssClass("ms-textXLarge");
        a.addCssClass("ms-heroCommandLink");
        a.addAttribute("title", newDiscussionTitle);
        a.renderBeginTag("a");
        a.addCssClass("ms-list-addnew-imgSpan20");
        a.renderBeginTag("span");
        a.addCssClass("ms-list-addnew-img20");
        a.addAttribute("src", GetThemedImageUrl("spcommon.png"));
        a.renderBeginTag("img");
        a.renderEndTag();
        a.renderEndTag();
        a.renderBeginTag("span");
        a.writeEncoded(newDiscussionTitle);
        a.renderEndTag();
        a.renderEndTag();
        a.addCssClass("ms-clear");
        a.renderBeginTag("div");
        a.renderEndTag();
        a.renderEndTag();
    }

1- Create New Js file, you can call it MyCustomJsFile.js

2- Copy the above code into it..

3- Put your file under layouts folder (you can even deploy it via visual studio)

4- Go to your list

5- Edit the current page (at the top right of the page just under site settings link)

6- Select the web part that the list is inserted in , Click Edit Web part

7- In miscellaneous- JsLink field insert the link to your js file this will be either

sp.ui.discussions.js | ~layouts/yourFileName.js 

or sp.ui.discussions.js | /_layouts/15/yourFileName.js

8- Click Apply

P.S: Step 6-7-8 can be done through modifiying the Schema.xml JsLink tag of the list in visual studio and deploying (still referring to the maintenability matter)

Enjoy :)

Hope this helps

0

You can edit a page where your discussion board resided and add a scrip webpart.

Inside script webpart use jQuery to find an element that holds the "new discussion" text and change it.

0

what about

SP.SOD.executeOrDelayUntilScriptLoaded(overrideOOTBStrings, 'initstrings.js');
SP.SOD.executeOrDelayUntilScriptLoaded(overrideOOTBStrings, 'strings.js');

// Change the default string values
function overrideOOTBStrings() {
    Strings.STS.L_SPDiscHeroLinkFormat='What ever you ewant";
}
0

The Solution suggested by 'Fares' is the approach for the specified question. while first solution details the exact steps and should be followed, the script completly removes the view tool bar.

SP.SOD.executeOrDelayUntilScriptLoaded(overrideOOTBStrings, 'initstrings.js');
SP.SOD.executeOrDelayUntilScriptLoaded(overrideOOTBStrings, 'strings.js');

// Change the default string values
function overrideOOTBStrings() {
    Strings.STS.L_SPDiscHeroLinkFormat='Add new pointers';
    Strings.STS.L_SPDiscSortMyPosts='My pointers';
}
  • adding through the scripts does not work if the webpart is refreshed using the refresh icon – Madhu May 19 '15 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.