Sharepoint 2013 Adding a add new event link in content editor - sharepoint

I would like to add a "Add New Event" link in a content editor web part to the calendar page. When clicked should open the default "new event" window to add an event. How can do that? what should be the link look like?
Thanks
Ganesh

If you want to open the form in the whole page, the link should be like this:
Add New Event
To open in a modal dialog:
function openDialog() {
var url = "<weburl>/Lists/<calendarlist>/NewForm.aspx";
var options = {
title: "Add New Event",
width: 400,
height: 600,
url: url
};
SP.UI.ModalDialog.showModalDialog(options);
}
Add New Event
Overwrite <weburl> with the web relative url and <calendarlist> with the relative url of the list (most of times the list name)
Example: https://mysiteurl/Lists/Calendar/NewForm.aspx

In a site page, click edit page and click on Add a Web Part.
Select your calendar list from Apps section in Categories.
Once your calendar is in your Site Page, click Add a Web Part again.
Select Content Editor Web part from Media and Contents section.
Inside Content Editor webpart click on "Click here to add new Contents"
From the ribbon, click on "Edit source".
[enter image description here][1]
Type or paste following code:
Add New Event
Lastly Click on Save page.

Related

Open another page in Dialog box

I am trying to use Dialog box.
In my add-in, I have two buttons openGoogle and openStackoverflow which link to openDialog("https://www.google.com") and openDialog("https://www.stackoverlfow.com"):
function openDialog(url) {
Office.context.ui.displayDialogAsync(url, { height: 1100, width: 1000 },
function (result) {
console.log("here")
dialog = result.value;
}
)
}
First, I open one dialog by clicking on openGoogle, then if I click on openStackoverflow, here is displayed again, however the dialog does NOT go to stackoverflow.
Does anyone know what's wrong?
From the documentation:
the page, controller method, or other resource that is passed to the
displayDialogAsync method must be in the same domain as the host page.
If you need to get users to another domain, you can do this by first opening a dialog to a page within your add-in that then immediately redirects them to the external domain using window.location.href = "https://www.stackoverlfow.com";

How to force a page to be displayed inside an ext:Panel?

This is about ext.net.
I have a link in West section, by clicking which, a webpage should be displayed in the Center section in a tab. But how to prevent the page from being rendered in a new browser window or tab (by shift click, or right click, then pick open in a new tab)?
I can suggest to use a LinkButton (if you really need your link to look as a link).
http://examples.ext.net/#/Buttons/Basic/LinkButton/
Handle its Click event and load any URL to the Center region.
App.PanelCenter.load({ url: "some URL" });
PanelCenter should be configured with a respective Loader.
Hope this helps.

Chrome extension: add option to right click menu when clicking certain HTML element

I want to create a Chrome extension that adds an option to the right click menu when the user right clicks a certain HTML element (for example a DIV with a known ID).
I would use this to add an option when the user right clicks a tweet on Twitter.com and that option would call a REST service.
Is this posible with a regultar Chrome extension?
Yes, these are called Context Menus. You can find the docs for those here: https://developer.chrome.com/extensions/contextMenus
Use chrome.contextMenus to add the option to right click
chrome.contextMenus.create({
title: 'test',
onclick: function(e){
console.log(e)
}
}, function(){})

Sharepoint links - how to open in new tab/Window

I've noticed with Sharepoint 2010, many of the links do not the support open in new tab/window feature. For example, items on the quick menu do not. Is it possible to enable?
Use the JavaScript function to open a new window in SharePoint 2010.
Create the function to open your target window as sample provide below.
function load_url(externallink)
{
window.open(externallink,target='_blank')
}
Place the function load_url in JavaScript file
Click site actions, select manage content and structure.
Suppose you want to change the links in the page
http://someserver/sites/Dev/Help/HelpLinks/AllItems.aspx
Then select the List named HelpLinks in the sub site Help. Dev will be the top most node(site). Help will be a sub site and inside Help you can find List by name HelpLinks.
All the links in the page and their title will be displayed
Select the title of link which you want to open in new tab and right click.
Select Edit properties. Then in the URL field and call the function as javascript:load_url('http://www.google.co.in'); instead of http:// www.google.co.in
Or Else
Suppose you want to change the links in the below URL.
URL: http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx
Go To
open to the link http:// someserver/sites/Dev/Help/HelpLinks/AllItems.aspx
You will find the columns of the List (Title Column, URL column, Summary etc).
Select the Title and click Edit property which you want to edit
Then in the URL field and call the function as javascript:load_url('http://www.google.co.in'); instead of http:// www.google.co.in
This answer is a recap of this article and is not an answer I came up with: http://sharepointsolutions.blogspot.com/2007/09/make-selected-links-in-links-list-open.html
Step 1: Add #openinnewwindow to the end of all hyperlinks you want to open in new window.
Step 2: Then you will need to add the follow script to your SharePoint pages.
[script language = "JavaScript"]
//add an entry to the _spBodyOnLoadFunctionNames array
//so that our function will run on the pageLoad event
_spBodyOnLoadFunctionNames.push("rewriteLinks");
function rewriteLinks() {
//create an array to store all the anchor elements in the page
var anchors = document.getElementsByTagName("a");
//loop through the array
for (var x = 0; x < anchors.length; x++) {
//does this anchor element contain #openinnewwindow?
if (anchors[x].outerHTML.indexOf('#openinnewwindow') > 0) {
//store the HTML for this anchor element
oldText = anchors[x].outerHTML;
//rewrite the URL to remove our test text and add a target instead
newText = oldText.replace(/#openinnewwindow/, '" target="_blank');
//write the HTML back to the browser
anchors[x].outerHTML = newText;
}
}
}
[/script]
Whats the 'Quick menu'? Do mean list item context menu or something else? Can you post a screenshot?
There are two types of links used.
Normal HTML anchors - You can hold down the CTRL key when clicking.
JavaScript links (menus and such) the CTRL key doesn't work. If you're working with the Edit/View forms then this may be of interest
SharePoint - Editing The SharePoint List Item Menu
Especially look for Part II where it talks about changing this behaviour in List Settings > Advanced Settings > Dialogs
This is actually an Internet Explorer specific bug. The navigation links in SharePoint 2010 are regular links but have two nested span tags around the text of the link. This confuses IE which doesn't realise that the text you are right-clicking up is a link and so doesn't give the correct context menu. If you right-click just to the left of the text of the link (the cursor should still show as the "hand") the context menu appears as expected.
For Sharepoint 2013, I used Keith's code with a delayed call.
<script type="text/javascript">
// Add an entry to the _spBodyOnLoadFunctionNames array
// so that our function will run on the pageLoad event
_spBodyOnLoadFunctionNames.push("rewriteLinks");
function rewriteLinks() {
$('a').attr("target","_blank");
}
</script>
In the SharePoint Wiki Editor, you can click the "From Address" Link you added, and a LINK menu will appear in the ribbon bar. Inside that, you can click "Open in New Tab" It's not exactly New Window, but it's close and easy.
Add this to the end of the link.
#openinnewwindow
example: http://www.bing.com**#openinnewwindow

SharePoint Add New Item Button on Home Page

I'm building a bulletin board site (in 2010) and I'm sure this must be simple but again it doesn't seem so. Anyway on my default page I have a query webpart showing the latest items and what I need is just a button at the top of the page "Add new item" which would show the popup and allow users to complete the form just like it works on the display list items form.
I've looked at AllItems.aspx but can't even see the "Add new item" button to copy!
Any ideas?
Thanks
Dan
This is actually very easy. You need to know the address for your NewForm.aspx page. To make it look like a dialog box, you want to add IsDlg=1 to the query string. SharePoint has a built in JavaScript that can do all this for you. Below is an example of a button I created to open new help desk tickets.
//Handle the DialogCallback callback
function DialogCallback(dialogResult, returnValue){}
//Open the Dialog
function OpenNewDialog(){
var options = {
url:"/depts/is/helpdesk/Lists/Service%20Requests/NewForm.aspx?IsDlg=1",
width: 700,
height: 700,
dialogReturnValueCallback: DialogCallback
};
SP.UI.ModalDialog.showModalDialog(options);
}
You can also leave off the width and height options and the dialog window will size itself. For the HTML
<div style="text-align: center">
Open a new Service Request
</div>
How complicated is your query? If the query is only pulling from one list, you could put the filters into a view in the list and replace your query webpart with a List View Web Part (in the browser, select the webpart named after your list). In the List View Web Part properties, switch to your new view. By default, a List View Web Part includes an Add New Item link.
Now, it's a link and not a button. And it's in the footer of the webpart, not at the the top. If you really need a button at the top of the page, you could add a Content Editor Web Part and insert HTML for your own button. You should be able to reuse the Add New Item URL from AllItems.aspx. The URL should look something like this: http://mysite/_layouts/listform.aspx?PageType=8&ListId={21AA3D96-75EE-45CC-A153-D0FA7856DE67}&RootFolder=

Resources