Sitecore 8.1 - 'Add' button to custom field type and Experience Editor - sitecore

Question that covers both the Experience (Page) Editor and the Content Editor.
I have a Timeline spotlight that users can add to a page - it has a list of decades at the top and underneath each decade there is a list of Years (with their text and images).
I have created a number of controls that link to various data sources but I'm finding the user experience lacking.
If I go to the Experience Editor:
Select Timeline Placeholder and Add Item
Popup comes up to select/create the data source
Then the only way to add a decade is by going to the Decade datasource, creating a new item there and then going back to the Timeline data source and adding this item their.
What I'm thinking of is:
Content Editor - Against the Timeline data item their is a multi-list field of 'Decades' - is there any easy way to add a 'Create' button next to it that would replicate the same event as if you went to the Decades data source and clicked insert item
Experience Editor - Remove the use of the Placeholder and add a similar 'Create' button that will replicate the insert item event - once item created and properties set refresh the control to display according.
Anyone came across something similar before? Any better solutions?
Thanks,
Dan

I'm actually working on the same features for our new implementation.
In Content editor, you might need to update core db.
In xEditor, you can use sitecore JS commands with ajax and back-end codes. My suggestion is that you can create a rendering component and assign the component into the named placeholder instead of remvoing it. Then, call the back-end and javascript events on the rendering item.
This could be a starting point.
Javascript
function:
function setDataSrc(itemID, templatePath, suffix, renderingID, dbName, deviceID, renderingUID, reload, callBack) {
var postReq = $.post("/handlePostRequest.aspx (or .cshtml)", {
method: 'methodName'
, itemID: itemID
, templatePath: templatePath
, suffix: suffix
, renderingID: renderingID
, dbName: dbName
, deviceID: deviceID
, renderingUID: renderingUID
});
postReq.done(function (data) {
if (reload != false) {
location.reload(true);
}
if (typeof callBack == 'function') {
callBack(data);
}
});
}

Got an answer from the Sitecore Community that might be helpful -
In experience editor you can create an edit frame button and use it for your rendering... from what i can see, your rendering data source points at "decades" folder. inside your rendering, check if you are in page editor and use a custom edit frame to display custom buttons. one of those will be an insert button to allow you to create a new child under "decades".
Full details in this blog post re Experience Editor Edit Frame Button.

Related

sitecore editframe button support multilanguage

I have been playing around with Editframe buttons in a Sitecore 8 for a multilingual project and I have the feeling that Edit Frame buttons do not work properly on sitecore multilingual sites.
Were you able to get it working edit frame buttons with a multilingual implementation?
Is it working out of the box or do you need any special configuration?
My experience is that when I am on a localized page and I click on an EditFrame button, it will open the default language Item instead of the localised item. I am of the impression that this is what happen when you click on Edit the Related Item in the Experience Editor.
I encountered your scenario very recently.
Were you able to get it working edit frame buttons with a multilingual implementation?
Yes, all the Fields I set up within the Edit Frame Buttons in the Core worked correctly with my Multilingual Site
Is it working out of the box or do you need any special configuration?
You need to add your Field Names into the Edit Frame Button Items in the Core database, found at the out-of-the-box path; /sitecore/content/Applications/WebEdit/Edit Frame Buttons/Default/Edit. Make sure your sc:Edit component references this path in the Buttons property
You may use different Display Names of the Fields for each of your languages for ease of use in the Content Editor / Experience Editor but as long as they are display Names it should be fine. If they are not and it doesn't work I recommend putting the Field Name for each language in the Edit Frame Item.
When I click on an EditFrame button, will it open the default language Item instead than the localised item, I am of the impression that this is what happen when you click on Edit The Related item as well
No, in both instances the Item will be loaded in the correct Language as well as when you create a new Datasource Item to be referenced by your Component.
The biggest issue that is present is when Edit the Relating Item and make changes to Rich Text Editor field or TreeEx field is that when you save it, it saves it to the default enlanguage, even creating a Language Version for it if it does not exist.
I have raised this issue with Sitecore Support and they are currently investigating. When they have a fix I'll update you with their solution.
EDIT
The Support Patch to resolve the issue Edit the Relating Item saving changes to the wrong language version of the Item can be found here - https://kb.sitecore.net/articles/814090

Which is the best approach to get the sitecore item on ajax call

Think about the scenario, where the page has to render the content dynamically when they do some operation on page.
Here basically, page will contain a list of rendering and in each rendering we will be able to get the current item using below statement.
var item = Sitecore.Mvc.Presentation.RenderingContext.Current.Rendering.Item;
Now if i have to show the content on button click, we will do a ajax call to our mvc controller/action, and in our Action we can render the item by following statements.
Item item = SitecoreHelper.GetSCDb().GetItem("{item id}");
or
Item item = SitecoreHelper.GetSCDb().GetItem("item path");
But in both the cases we have to hardcode the id/path.
So can anyone tell me, is there any better approach to do this.
I appreciate your help.
Cheers:)
Something I've done on Sitecore + MVC projects was for content items that are going to be accessed by both Page Editor and by AJAX calls in JavaScript, is creating a new device in that items template _StandardValues, in that I set the query to ?Ajax=true. I then put only the HTML piece (without styles, and JS) as the layout. While the desktop view has what it would look like "after" it's been called by AJAX. This doesn't need any .net coding, it's all done via sitecore.

How To Add JSLink For Calendar Event

I'm using sharepoint 2013 and i want to utilize the client side rendering feature using JSLink, when editing the web part for the calendar new event, in the "miscellaneous" there is no field for JSLink, how to modify the render for new event using JSLink ?.
It is not possible. See this discussion.
After about an hour's worth of research I found the problem. Microsoft specifically targets the Invalid, Event, and Survey list types to ignore client rendering. Unless you create your own webpart you will not ever be able to use any of the JSLink properties for these list types. Maybe somebody at Microsoft can explain themselves here as to why they would have crippled us like that or what a proper approach for this common problem would be. Yet another reason the Calendar is a piece of garbage in SharePoint 2013!
Also this answer:
There is no OOTB way to attach Javascript with calendar view (no property exposed for that listview). For a workaround you can create your own JQUERY or JAVASCRIPT and add on calendar view page by adding the reference in Content Editor Webpart on that page.,
However I have a quick but dirty solution. Add a SriptEditor to yout page, below the calendar and insert:
var oldEditLink = EditLink2;
EditLink2 = function(a,b,c){
if (isNaN(b) && b.substring(0,3) == "WPQ"){
var itemId = a.getAttribute("href").split("=")[1];
// do what you want to do
return false;
}
oldEditLink(a,b,c);
}

go to the most recent state on clicking the back button

Im building a website using django. On my display page, I have a list of items (with the name results), and I have filters which filter "results" and get another list "filtered" on the display page using an ajax call.
Now when I go to some other page, and then click the back button, I get back to the page with the filters selected, but the results are not filtered (I would want the "filters" list rather than the "results" list on going back). How do I get to the most recent state after using the back button? Basically, everything done using javascript and the subsequent actions get flushed.
Can anyone help me with this. Thanks.
Browser history behavior gets complex, but one technique I've used is to embed the state in the hash. That will make the browser treat each different hash value as a different page in the history, and also lets you do things like bookmark a particular filter selection state. I used jquery, along these lines:
$(function() {
if (window.location.hash) {
// parse the hash and update your filter settings, then get the content and display it
};
function update_hash() {
// calculate the hash based on your filter
window.location.hash = new_hash;
};
};
Then bind update_hash as an event handler for changes.

How can I programatically select a sitecore content tree item and expand it?

How can I programatically select a sitecore content tree item and expand it ?
Sitecore version: 6.2
By expanding, I mean expanding the content tree item like in windows explorer ("+").
Ok, I suppose this code will be triggered from somewhere in Content Editor, e.g. by clicking the ribbon button. Then you might need something like this:
// it is up to you where to get the item from
Sitecore.Context.ClientPage.SendMessage(this, string.Concat(new object[] { "item:load(id=", item.ID.ToString(), ")" }));
Sitecore.Context.ClientPage.SendMessage(this, "item:refreshchildren");
I can't imagine the scenario when you might need this functionality, but hope this helps. :)
this might be a late reply but you can get all the side menu items via Sitecore API in a repeater or listview control within <ul>s and <li>s and then use a jQuery plug-in/CSS to [+] or [-] the side menu. I have done this on a site, if you need more information I can send you an example