Can I have flexible/catchall regions with Tridion XM/New UI/2012 UI - tridion

I am putting together a functional design for a site which will aims use the Tridion 2012 UI/XM to manage pages. There are 2 regions on the page, a main content area on the left and a side-bar on the right. Ideally users should be able to drag and drop content into and within these regions. In an ideal world I would like to define the regions along the lines of
Side Bar: any CP for which the CT has the text 'Right' in it.
Main: all other CPs
Looking at the documentation it seems that you need to explicitly use CT/Schema ID pairs to define regions. Is there any possibility to do this in any other way?
At the very least I would like to be able to define that the side bar allows a certain fixed set of CT/Schema ID pairs, but have the main region as a catchall bucket.. Is this possible?
It is also possible that the Side Bar is split into 2 regions, above and below an advertisement. Both regions should allow the same types of CP - as far as I understand this is not possible - is this correct? Are there any ideas for workarounds?

To configure regions that take all Content Types, You need to get Publication AppData and loop through the content types and build your json markup for enabling this.You could write C# TBB which includes on each page template and does this logic, you can define some metadata at CT level which determines which region it will go in and build the Region JSON markup.
Below is the snippet to get all Component types to add in one region. You could change the logic to get only right just by checking the template name.
// get the publication from the engine -- using TemplateBase Util..
Publication thisPub = GetPublication();
XmlElement seAppdata = thisPub.LoadApplicationData("SiteEdit").GetAs<XmlElement>();
XmlNamespaceManager seNsMgr = new XmlNamespaceManager(new NameTable());
seNsMgr.AddNamespace("se", "http://www.sdltridion.com/2011/SiteEdit");
seNsMgr.AddNamespace("xlink", "http://www.w3.org/1999/xlink");
XmlNodeList contentTypes = (XmlNodeList)seAppdata.SelectNodes("//se:ContentTypes/se:ContentType", seNsMgr);
List<String> contentTypeJson = new List<String>();
foreach (XmlNode contentType in contentTypes)
{
string templateId = contentType.SelectSingleNode("se:ComponentTemplate/#xlink:href", seNsMgr).Value;
string componentId = contentType.SelectSingleNode("se:Component/#xlink:href", seNsMgr).Value;
Component thisSchema = (Component)engine.GetObject(componentId);
string schemaId = thisSchema.Schema.Id;
// Add json formated string for Content Types
contentTypeJson.Add(string.Format("{{schema: \"{0}\", template: \"{1}\"}}", schemaId, templateId));
}
// Final Markup - JSON
String allRegionSeText = string.Format("<!-- Start Region: {{title: \"All Region\", allowedComponentTypes: [{0}], minOccurs: 1, maxOccurs: 5 }} -->", string.Join(",", contentTypeJson.ToArray()));
// Push to the package to use in DWT..
package.PushItem("ALL_REGION", package.CreateStringItem(ContentType.Text, allRegionSeText));
Hope this helps.

Have you tried creating a region without specifying CT/Schema pairs? I remember seeing in an early implementation that you could drop a content type anywhere because regions hadn't been configured properly (or perhaps at all).

Related

How to dynamically load image into picturebox in fast report?

I have a table in Sql that has 2 columns containing header and address of images that related to that header like below:
Header address
194003 ~/viewerImages/1903-01-1-5-0-6-00143.jpg
194003 ~/viewerImages/1903-01-1-5-0-6-00161.jpg
194003 ~/viewerImages/1903-01-1-5-0-6-00190.jpg
194012 ~/viewerImages/1903-01-1-5-0-6-00143.jpg
194012 ~/viewerImages/1903-01-1-5-0-7-00141.jpg
194012 ~/viewerImages/1903-01-1-5-0-7-00160.jpg
194015 ~/viewerImages/1903-01-1-5-0-7-00180.jpg
194015 ~/viewerImages/1903-01-1-5-0-8-00159.jpg
194015 ~/viewerImages/1903-01-1-5-0-8-00184.jpg
I want to load these images dynamically in fastreport for each header.
what should I do?
One solution is to create an objet with some properties that are the images to load (image1, image2, image3). You also add more properties with the data that you want to print in the report.
Then, you can load the information in the object dinamically and after send the object to the report, so Fast Reports will print the information you are loading in the object. In this way you can do wharever you want dinamically.
For image properties, you can use Image or byte[] type.
To create the report:
var report = new Report();
report.Load(Constants.Paths.ReportFolder + "Return.frx");
report.RegisterData(myObject, "Name");
report.Design(); // if you want to open the designer before to print
report.Show();
Note: The object to register must be a collection of objects. In this case myObject would be a List. If you want to register a single object, you can do it in this way:
report.RegisterData(new List{ myObject }), "Name");
In the designer you can access all the properties.

Render Node by Id in Umbraco 4.11

TL;DR How do you render a content item by Node Id.
I'm using Widget Grid admin extension for Umbraco to configure a content manageable widget area and I'm stuck trying to render the configured widgets.
I have a list of node id's that I want to render on the page but I can for the life of me work out how to do this.
Any guidance is greatly appreciated! Thanks.
UPDATE
Xml contained within the Models property
<WidgetGrid>
<col1> <nodeId>4839</nodeId> <nodeId>4844</nodeId> <nodeId>4845</nodeId> </col1>
</WidgetGrid>
Once I get down to col1 it seems to cease being of type DynamicXml and just spits it out as a string... No idea.
Presumably you're doing this from within a macro, and I'm going to presume you have a multi-node picker set to store the Id values as CSV:
#{
string[] widgetIds = ((string)Model.Widgets).Split(',');
foreach (var id in widgetIds)
{
var widget = Model.NodeById(id);
#RenderPage("~/macroscripts/widgets/" + widget.NodeTypeAlias
+ ".cshtml", widget);
}
}
This will let you select different types of widget in your multi-node picker, and have a different view for each widget.
This also uses the dynamic approach but you could easily adapt this by swapping the first line for:
string[] podIds = CurrentModel.GetProperty<string>("widgets").Split(',');
Given that the property is stored as XML, you can use the notation as described in this post (http://umbraco.com/follow-us/blog-archive/2011/2/28/umbraco-razor-feature-walkthrough-%E2%80%93-part-3):
foreach (var id in Model.widgets.col1[0].nodeId)
{
...
}

Get shared pages using localized component

I'm currently working on a event handler, which will on save-event, save the latest revision date of the page and it's components into a custom database, and this is working, but i'm facing some performance issues.
Let me give you an example, for how it's working:
If a component is saved/updated (changes are made), then I want to update all pages using this component in my custom database.
Basic blueprint setup:
200 contains components
400 translation publication for components (inherent components from 200)
500 master publication for pages
600 local site publication inherent components from 400 and pages from 500)
So lets say we have component X in 200, this component is included in in a page in 500, X is localized in 400 (let us call it X(l)) and the page in 600 is NOT localized ( i.e it will use the component x(l))
So now to my question:
In my save event handler, i check what pages X(l) are included in , by using :
var filter = new UsingItemsFilter(component.Session)
{
IncludeLocalCopies = true,
ItemTypes = new[] { ItemType.Page }
};
but this will only give me references to pages from 500.
So what i then do (which feels kind of stupid) is to
create a tcm id of all pages in child publications(by looping over them) that inherent this page (now im using some psuedocodelike coding):
foreach(var 500page in foundPages)
foreach(var publication in publications){
if(subject.Session.IsExistingObject(
new TcmUri(page.Id.ItemId,page.Id.ItemType,publication.Id.ItemId)
))
{
someListThatWillContainAllChildPagesFrom500.Add(TheAboveTcmUri);
}
}
And then for each page, check the components in that page, and finally save this state to my custom database.
So the question is, is there a way by to query for all pages, that make use of the localized component, by using the TOM.NET api (no not CoreServiceClient)?
Is there a better way to find child publications of a publication, so I only need to check for pages in the childPublication?
Br Martin
The following code sample should give you the shared items of a specific local/localized item along with the item. BluePrintNodesFilter was introduced in 2013, however in earlier version BluePrintFilter should work in similar way.
SystemManager systemManager = session.SystemManager;
BluePrintNodesFilter filter = new BluePrintNodesFilter(session)
{
BaseColumns = ListBaseColumns.Id,
ForItem = page
};
IEnumerable<BluePrintNode> allNodes = systemManager.GetBluePrintNodes(filter);
IEnumerable<RepositoryLocalObject> sharedAndLocal = (from node in allNodes
where node.Item != null
where node.Item.OwningRepository.Id == page.OwningRepository.Id
select node.Item).ToArray();

SDL Tridion GetListKeywords using Anquilla Framework

I'm writing a GUI extension and using the Anquilla framework to get a list of Keywords within a Category. I'm obtaining an XML document for the list of keywords then working with that document within my extension.
My problem is that the returned XML doesn't contain the Keyword's 'Description' value. I have the Title and Key etc.
My original code looks like this:
var category = $models.getItem("CATEGORYTCMID:);
var list = category.getListKeywords();
list.getXml();
A typical node returned is this:
<tcm:Item ID="tcm:4-1749-1024"
Type="1024" Title="rate_one" Lock="0" IsRoot="true"
Modified="2012-12-17T23:01:59" FromPub="010 Schema"
Key="rate_one_value" IsAbstract="false"
CategoryTitle="TagSelector"
CategoryID="tcm:4-469-512" Icon="T1024L0P0"
Allow="268560384" Deny="96" IsNew="false"
Managed="1024"/></tcm:ListKeywords>
So I've tried using a Filter to give me additional column information:
var filter = new Tridion.ContentManager.ListFilter();
filter.columns = Tridion.Constants.ColumnFilter.EXTENDED;
var list = category.getListKeywords(filter);
Unfortunately this only gives the additional XML attributes:
IsShared="true" IsLocalized="false"
I'd really like the description value to be part of this XML without having to create a Keyword object from the XML. Is such a thing possible?
cough any ideas? cough
I'm afraid you'll have to load the Keyword itself to get the Description.
It's not used in any lists, so it's not returned in the XML.
You could always create a List Extender to add this information to the list, but try to be smart about it since this extender will execute everytime a GetList is called.
Won't save you from having to open every keyword in the list, but you'll be doing it server-side (with Core Service/NetTcp for instance) which will probably be easier and faster than opening each keyword with Anguilla.
In this instance I only need the one keyword, so I simply get it from the CMS. Getting an object in Anguilla is a bit weird, here's the code:
In your main code area:
var selectedKy = $models.getItem("TcmUriOfKeywordHere");
if (selectedKy.isLoaded()) {
p.selectedKy = selectedKy;
this.onselectedKyLoaded();
} else {
$evt.addEventHandler(selectedKy, "load", this.onselectedKyLoaded);
selectedKy.load();
}
It's worth noting how I store the keyword in the properties of the item, so I can obtain it in the onselectedKyLoaded function
The function called once the item is loaded
ContentBloom.ExampleGuiExtension.prototype.onselectedKyLoaded = function (event) {
var p = this.properties;
var selectedDescription = p.selectedKy.getDescription();
// do what you need to do with the description :)
};
I resolved this, thanks to the answer here: https://stackoverflow.com/a/12805939/1221032 - Cheers Nuno :)

Flex: create buttons dynamically and assign value from txt file

I made a basic text editor that lets users insert predefined strings into the document with button clicks. What I need to do now is let the user define their own buttons and string values.
For example I have a button that inserts "Hello" into the text. The user may want to create a button that adds "Goodbye".
To accomplish this I figured I would create a .txt file called buttons.txt or something. i would readutfbytee, loop through it to create the buttons. problem is I know what I want to do but not sure where to start. Can someone give me a kick start?
Please check the following code as the simple way to externalize your button settings:
/*
buttons.txt content sample:
Helo=Hello World&Test=Test Inserted
*/
protected function loadSettings():void
{
var varLoader:URLLoader = new URLLoader();
varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
varLoader.addEventListener(Event.COMPLETE, onSettingsLoaded);
varLoader.load(new URLRequest("data/buttons.txt"));
}
protected function onSettingsLoaded(event:Event):void
{
var varLoader:URLLoader = URLLoader(event.target);
var varButtons:URLVariables = varLoader.data;
var buttons:Dictionary = new Dictionary();
for(var label:String in varButtons{
buttons[label]=varButtons[label].toString().split(",");
}
//use parsed buttons dictionary
}
For starters you need to decide how you are going to store that data that the user enters.
A flex web app can't save any files to the server, so if you want to save this across multiple computers, you'll need a server to do the data saving / retrieval.
If you want to store the buttons just temporarily, and unique to one computer, you can stuff them into a SharedObject.
After you decide this, then you can get more specific on a question of how to do exactly what you're wanting.

Resources