Problems with new 2sxc faq app - 2sxc

Anyone had any luck with this?
I'm using 9.04.01 on DNN 9.
There doesn't appear to be a way to add a question unlike it's previous version.
The previous version had a + sign in the menu on the right to add a new question. This version doesn't. Is there a different way to add questions in this version?
Images http://robertveale.com/
Thanks.

You actually ran into something different. Please check http://2sxc.org/en/blog/post/12-differences-when-templating-data-instead-of-content to understand this
Your first view shows a list of content-assigned-to-the-module so you have the inline +.
The second view shows a list querying the DB, so hitting + wouldn't add it below that but anywhere else, so it's not part of the item-toolbar. If you need a + on the query-view, then the most common solution is to provide a separate + button - see for example how the blog-app does it here: https://github.com/2sic/app-blog/blob/master/_1%20Main%20blog%20view.cshtml#L24-L38
#* toolbar for add / manage posts *#
#Edit.Toolbar(toolbar: new object[] {
new {
command = new {
action = "new",
contentType = "BlogPost"
}
},
new {
command = new {
action = "contentitems",
contentType = "BlogPost"
},
showCondition = true
}
}, settings: new { hover="left", show = "hover" })

Related

aspnetawesome grid databinding not working

I have been using AweomeGrid for about 2 mvc4 Projects Now and It has been working fine, However I am completely bumped when I tried the mvc5 Branch. I basically have a grid and controller setup as follows
#Html.Awe().Grid("grdZone")
.Groupable(false)
.Url(Url.Action("ZoneRead", "Setup"))
.PageSize(20)
.Columns(
new Column(){ Name = "Id", Width = 70 },
new Column(){ Name = "Name" },
new Column(){ Name = "GCount", Header = "Group Count", Width = 100})
And the controller listing is as follows
public ActionResult ZoneRead(GridParams g)
{
var model = _zoneService.GetAll().Select(i => new ZoneListModel
{
Id = i.Id,
GCount = i.Groups.Count(),
Name = i.Name
});
return Json(new GridModelBuilder<ZoneListModel>(model, g)
{
Key = "Id",
Map = o => new
{
o.Id,
o.Name,
o.GCount
}
}.Build());
}
The problem is that The controller actually returns the data but somehow strangely, The Grid just displays empty table cells without any values at all. The number of empty rows displayed however corresponda to the records returned by the controller method
Please what Am I doing wrong
A speedy answer will be appreaciated
it's possible that on mvc5 you're using minification, and the minification broke the script, try adding AwesomeMvc.js without including it in a script bundle
(btw using version 4.7 this shouldn't happen anymore)

find last editor aka author of Item in Sitecore

Ok I've used this in the past to get last editor and it works great when running on sites that use workflow but it doesnt return any users for sites that do not use workflow..
var contentWorkflow = contentItem.Database.WorkflowProvider.GetWorkflow(contentItem);
var contentHistory = contentWorkflow.GetHistory(contentItem);
if (contentHistory.Length > 0)
{
//submitting user (string)
string lastUser = contentHistory[contentHistory.Length - 1].User;
}
Can you reply with a way to get last editor of an item regardless of whether they use workflow or not?
Thanks
Try to use
contentItem.Statistics.UpdatedBy
You can check more members of the ItemStatistics class here.

setting IsEditable=false for item disables save/close button but not save button?

I developed a data extender class that acts on GetItem and CheckOutItem commands to do some business-specific validation to determine whether the user should have access to modify the item or not (basically if it's past the initial "author" task in workflow, no one can edit it. by default Tridion allows "reviewers" in workflow to edit the item, which is a no-no in our business).
I am relatively certain this worked at one point, but now does not. I'm exploring what might have changed, but I thought I'd ask here in case anyone has an idea.
If the item can't be modified, I'm setting the IsEditable attribute to false. This does in fact disable the Save and Close button and Save and New button, but for some reason the Save button is enabled. I don't quite understand why there could be a difference. (I'm looking to see if someone extended the save button somehow, but I don't see that being done). Any thoughts on how the Save button would enable when the others aren't?
thanks for any suggestions,
~Warner
public override XmlTextReader ProcessResponse(XmlTextReader reader, PipelineContext context)
{
using (new Tridion.Logging.Tracer())
{
string command = context.Parameters["command"].ToString();
if (command == CHECKOUT_COMMAND || command == GETITEM_COMMAND)
{
XmlDocument xmlDoc = ExtenderUtil.GetExtenderAsXmlDocument(reader);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("tcm", Constants.TcmNamespace);
try
{
//is this a page or component?
XmlNode thisItemNode = null;
thisItemNode = xmlDoc.SelectSingleNode("//tcm:Component", nsmgr) ?? xmlDoc.SelectSingleNode("//tcm:Page", nsmgr);
if (thisItemNode == null) return ExtenderUtil.GetExtenderAsXmlTextReader(xmlDoc);
// need to impersonate system admin in order to get workflow version of item later
Session sessionSystemAdmin = Util.SystemAdminSession;
XmlAttribute idAttribute = thisItemNode.Attributes.GetNamedItem("ID") as XmlAttribute;
//if ID attribute is null, we don't have the actual object being used (just a referenced item. so, we'll ignore it)
if (idAttribute != null)
{
string itemId = idAttribute.Value;
VersionedItem tridionObject = Util.ObtainValidTridionIdentifiableObject(sessionSystemAdmin, itemId) as VersionedItem;
//logic has been moved to separate method, just for maintainablility...
//the logic may change when workflow code is finished.
bool allowSave = IsItemValidForEdit(tridionObject, nsmgr);
if (!allowSave)
{
//not the WIP ("author") task... make item read-only
Logger.WriteVerbose("setting iseditable to false for item: " + itemId);
XmlAttribute isEditableAttribute = thisItemNode.Attributes.GetNamedItem("IsEditable") as XmlAttribute;
isEditableAttribute.Value = "false";
}
}
}
catch (Exception e)
{
Logger.WriteError("problem with get item data extender", ErrorCode.CMS_DATAEXTENDER_GETITEM_FAILURE, e);
}
return ExtenderUtil.GetExtenderAsXmlTextReader(xmlDoc);
}
else
{
return reader;
}
}
}
Most of the Tridion GUI probably bases the options it presents on the so-called Allowed Actions. This is a combination of the Allow and Deny attributes that are present in list-calls (if requested) and item XML.
So at the very least you will have to remove the CheckIn and Edit action from the Allow attribute (and probably add them to the Deny attribute). If you look at the Core Service documentation (or any other Tridion API documentation: these values haven't changed in a long time) you can find an Enum called Actions that hold the possible actions and their corresponding values. The Allow and Deny attributes are simply additions of these numbers.
The CheckIn action I mention is number 2, Edit is 2048.
Update:
I have a little command line program to decode the AllowedActions for me. To celebrate your question, I quickly converted it into a web page that you can find here. The main work horse is below and shows both how you can decode the number and how you can manipulate it. In this case it's all subtraction, but you can just as easily add an allowed action by adding a number to it.
var AllowedActionsEnum = {
AbortAction: 134217728,
ExecuteAction: 67108864,
FinishProcessAction: 33554432,
RestartActivityAction: 16777216,
FinishActivityAction: 8388608,
StartActivityAction: 4194304,
BlueprintManagedAction: 2097152,
WorkflowManagedAction: 1048576,
PermissionManagedAction: 524288,
EnableAction: 131072,
CopyAction: 65536,
CutAction: 32768,
DeleteAction: 16384,
ViewAction: 8192,
EditAction: 2048,
SearchAction: 1024,
RePublishAction: 512,
UnPublishAction: 256,
PublishAction: 128,
UnLocalizeAction: 64,
LocalizeAction: 32,
RollbackAction: 16,
HistoryListAction: 8,
UndoCheckOutAction: 4,
CheckInAction: 2,
CheckOutAction: 1
};
function decode() {
var original = left = parseInt(prompt('Specify Allow/Deny actions'));
var msg = "";
for (var action in AllowedActionsEnum) {
if (left >= AllowedActionsEnum[action]) {
msg += '\n' + action + ' ('+AllowedActionsEnum[action]+')';
left -= AllowedActionsEnum[action];
}
}
alert(original+msg);
}
The solution is to really look over the entire solution and be absolutely positive that nobody snuck something in recently that messes with the Save button and is magically enabling it behind the scenes. I've re-edited the code to show how I initially had it. And it does work. It will disable the save, save/close, save/new buttons and make all fields disabled. I'm sorry that I wasted Frank's time. Hopefully having this here for historical purposes may come in handy for someone else with similar requirements in the future.

How to pass javascript value in Razor syntax(as a parameter value)

i am using jquery grid in MVC 3 .as a formatter option i am using following code as a script segment.
function viewformateadorLink(cellvalue, options, rowObject) {
return "" + cellvalue + "";
}
but i don't want to use href here .better option i have found is as follows:
func....(){
var url = '#Html.ActionLink( "_name_", "Edit", new { id = "_id_" })';
url = url.replace(/_name_/, cellvalue);
url = url.replace(/_id_/, rowObject[0]);
return url;
}
are there any simple way exist for passing parameter?
If the value you want to pass to the link is in a JavaScript variable and you don't want to use href, then I'm afraid you can't go further than you already have gone and this is why:
The JavaScript code is ALWAYS executed after the server-side code.
I imagine you would like to do something like:
#Html.ActionLink( "_name_", "Edit", new { id = *JAVASCRIPT VARIABLE* })
but due to the reason I mentioned above, such thing is impossible.
I would suggest you stick to any of the other methods you used in your question.

Javascript permission denied error when using Atalasoft DotImage

Have a real puzzler here. I'm using Atalasoft DotImage to allow the user to add some annotations to an image. When I add two annotations of the same type that contain text that have the same name, I get a javascript permission denied error in the Atalasoft's compressed js. The error is accessing the style member of a rule:
In the debugger (Visual Studio 2010 .Net 4.0) I can access
h._rule
but not
h._rule.style
What in javascript would cause permission denied when accessing a membere of an object?
Just wondering if anyone else has encountered this. I see several people using Atalasoft on SO and I even saw a response from someone with Atalasoft. And yes, I'm talking to them, but it never hurts to throw it out to the crowd. This only happens in IE8, not FireFox.
Thanks, Brian
Updates: Yes, using latest version: 9.0.2.43666
By same name (see comment below) I mean, I created default annotations and they are named so they can be added with javascript later.
// create a default annotation
TextData text = new TextData();
text.Name = "DefaultTextAnnotation";
text.Text = "Default Text Annotation:\n double-click to edit";
//text.Font = new AnnotationFont("Arial", 12f);
text.Font = new AnnotationFont(_strAnnotationFontName, _fltAnnotationFontSize);
text.Font.Bold = true;
text.FontBrush = new AnnotationBrush(Color.Black);
text.Fill = new AnnotationBrush(Color.Ivory);
text.Outline = new AnnotationPen(new AnnotationBrush(Color.White), 2);
WebAnnotationViewer1.Annotations.DefaultAnnotations.Add(text);
In javascript:
CreateAnnotation('TextData', 'DefaultTextAnnotation');
function CreateAnnotation(type, name) {
SetAnnotationModified(true);
WebAnnotationViewer1.DeselectAll();
var ann = WebAnnotationViewer1.CreateAnnotation(type, name);
WebThumbnailViewer1.Update();
}
There was a bug in an earlier version that allowed annotations to be saved with the same unique id's. This generally doesn't cause problems for any annotations except for TextAnnotations, since they use the unique id to create a CSS class for the text editor. CSS doesn't like having two or more classes defined by the same name, this is what causes the "Permission denied" error.
You can remove the unique id's from the annotations without it causing problems. I have provided a few code snippets below that demonstrate how this can be done. Calling ResetUniques() after you load the annotation data (on the server side) should make everything run smoothly.
-Dave C. from Atalasoft
protected void ResetUniques()
{
foreach (LayerAnnotation layerAnn in WebAnnotationViewer1.Annotations.Layers)
{
ResetLayer(layerAnn.Data as LayerData);
}
}
protected void ResetLayer(LayerData layer)
{
ResetUniqueID(layer);
foreach (AnnotationData data in layer.Items)
{
LayerData group = data as LayerData;
if (group != null)
{
ResetLayer(data as LayerData);
}
else
{
ResetUniqueID(data);
}
}
}
protected void ResetUniqueID(AnnotationData data)
{
data.SetExtraProperty("_atalaUniqueIndex", null);
}

Resources