I assume its the itemStyle.xsl that I need to customize, but what is the code to add a "new Item Link to the bottom of a Content Query Web Part that takes you to the modalDialog for a new list item?


1 Answer 1


The CQWP is tricky because it might roll-up content from multiple sites, sub-sites and lists, which practically means that items could be mixed comming from different lists, therefore your URL will change everytime. The obvious question will be - New item to be added into which list, under which site?

Cannot deliver full code but - link to the NewForm.aspx - for which you need to know the URL of the item to deduct the ListItem or at least you would need the List Id

function Opendialog() {
       var options = SP.UI.$create_DialogOptions();
       options.resizable = 1;
       options.scroll = 1;
       options.url = YourSiteURL + "/_layouts/listform.aspx?PageType=8&ListId={PUT-LIST-GUID-HERE}";
       options.dialogReturnValueCallback = Function.createDelegate(null, CloseCallback);

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.