I played around with alot of ideas, using security and disallowing everyone from creating new discussions, using CSS etc, but in the end the answer was surprisingly simple.
I found a javascript function on someone's blog (I'd credit him if I could find it again, too many blogs & Christmas & New Year in between). This javascript function, when added to master page, removed all New items from list menus that are document library types.
Ok, not exactly what I want, but at least a start. So I tried modding the javascript to work with my new feature off the masterpage. No luck. Then I played around with the CEWP, adding it to my forum. Worked like a charm, but I need to add alot of functionality besides this one and I could just extend the new template list with it's CEWP added.
Finally, the solution I found was: Add the javascript to the AllItems.aspx page of my forum, to the content area of the main place holder. Success!
This is the javascript:
function HideNewQADiscussionMenuItem()
{
try
{
var tables = document.getElementsByTagName("table");
for(var i=0; i<> 0 )
{
var elm = tables[i];
elm.parentElement.parentElement.style.display="none";
elm.parentElement.parentElement.nextSibling.style.display="none";
}
}
}
catch(e)
{
}
}
And here's how it fits in:
The last line is:
if(!document.all){ window.onload=HideNewQADiscussionMenuItem; }else{ HideNewQADiscussionMenuItem(); }
This makes sure the javascript is called when the page is loaded. And that removes the New fucntion from the top menu of my dicussion forum.
Step by Step:
- Create a new visual studio project, select List Definition from the SharePoint projects. Select the basic list to inherit from, in my case Discussions. This creates all ASPX files & XML files needed for a list definition.
- Open the AllItems.aspx file
- Find the PlaceHolderMain content tag.
- Below the web part zone, add the javascript. Remember the javascript tag & the line of code to make sure the javascript is called (I couldn't figure out why my script wasn't being called :P )
- Build & Deploy the solution (Visual Studio should have this option under the build menu, if it doesn't, you deploy the list definition as a feature).
And that's that. Your new list is ready for use. Of course, you now need some way to create new list items :)
No comments:
Post a Comment