Generate page url rather than data id with JSON in Umbraco - json

(Please bare in mind that I am new to Umbraco and JSON!)
In Umbraco, I'm looking to use JSON (alongside HTML and CSS) to turn grid cells into buttons. So far I've accomplished this using the below code (generated from an amalgamation of different tutorials/guides), but this is generating urls which end with the numerical data-id of the page. E.g. www.mywebsite.com/0000/. This works as a link and goes to the correct place, but I'd much rather it generated a URL with the correct name? I.e. something more like www.mywebsite.com/page-name/.
How can this be done?
{
"label": "destination",
"description": "Choose destination",
"view": "treepicker",
"key": "class=\"button\"><a class=\"buttonLink\" href",
"applyTo": "cell"
}
]

If you are using Umbraco, then you can easily get the URL or URlName of the page you are on.
IPublishedContent has all these properties and you can inherit this interface to your class to access these.
Thanks

Related

`versions:batch-get` doesn't fetch the "Title" Custom Attribute

I've been trying to get the "Title" attribute of documents within my projects' Plans folder, but the sheets number/displayName appears in the title field of the response:
{
"urn": "urn:adsk.wipprod:fs.file:[...]version=1",
"itemUrn": "urn:adsk.wipprod:dm.lineage:[...]",
"name": "A13.3",
"title": "A13.3", // <- Here
"...": "...",
"customAttributes": [], // <- Nothing here, even if I modify the "Title value"
"number": "A13.3"
}
Is this intentional? Or have I misunderstood? I can't find any other endpoint which has documentation suggesting it'll fetch the Title attribute. I see that the BIM360 web app is using the legacy endpoint to fetch this property for itself:
projects/:project_id/folders/:folder_id/custom_attributes.
I know this is similar to a previous question, but it seems that was asked well over a year ago when there was no versions:batch-get endpoint.
Thank you in advance!
The documentation you mentioned is out-of-date. Please check this one instead:
https://forge.autodesk.com/en/docs/bim360/v1/reference/http/document-management-versionsbatch-get-POST
The fields like title, displayName and name are Docs built-in custom attributes and will appear in response of POST versions:batch-get only, not in GET custom-attribute-definitions.
Besides, the customAttributes field of POST versions:batch-get and GET custom-attribute-definitions are for user-created custom attributes only. If you don't assign any value to your user-created custom attributes to either the document or file of your Docs project, then customAttributes field will be empty. Here is the field description from the documentation.
The list of custom attributes for each document. For more information about custom attributes, see the Customize Documents with Attributes documentation.

schema.org json-ld using coldfusion

I have not used json with coldfusion hence looking for some advice. I am trying to use coldfusion to get the schema.org json-ld work on a website. I have a query coming from a component which has the data that needs to go in the json. Can someone give me a gist of what needs to be done in order to spit out the json from the query in the below script tags on the page. Thanks in advance.
<script type="application/ld+json"></script>
I used this JSON-LD Schema Markup Generator to determine the fields and schema to use and then created a ColdFusion struct that matched it. For some elements (addresses, social media URLs, multiple locations), you'll need to create an array-of-structs.
There are many optional parameters you can add to each markup type, so it's difficult to program a one-size-fits-all solution. (I finally managed to write a custom tag that works specifically with our internal/custom CMS to auto-generate this for our client webpages.)
Here's a bare-bones ColdFusion sample for type "WebSite". (We've been adding inlining the JSON to the same webpage.)
<cfscript>
SchemaData = {
"#context" = "http://www.schema.org",
"#type" = "WebSite",
"name" = "My Website",
"alternateName" = "My Alternate Website Title (optional)",
"url" = "https://www.mywebsite.com/"
};
writeoutput('<script type="application/ld+json">#SchemaData#</script>');
</cfscript>

Displaying Google Spreadsheet Data with json2html

I'm interested in using json2html to display Google spreadsheet data
on a website.
Specifically, to display contents of this feed on a page:
https://spreadsheets.google.com/feeds/list/0Am0zfph_qjJMdEJrOTQxQ3A1N2xneU9ac003Szd2MVE/od6/public/basic?alt=json-in-script
Under the "Examples" tab on the json2html website, there's a sample for displaying the NHL's feed. This is pretty much what I'm trying to accomplish, but I'm not entirely sure which json tag would go where in the script markup.
Any ideas?
Depends on how you want to display the data (and which data). For now I'm assuming that you want to display the cell entries. Here is something to get you started (note you can also use the jquery plugin with the same transform)
var transform =
{"tag": "li", "children": [
{"tag":"p", "html":"${content.$t}"},
]};
var data = json2html.transform(gData.feed.entry,transform);
document.write('<ul>'+ data + '<ul>');

property rootNode in struts2-jquery-tree-plugin doesn't run

I'm testing struts2 jquery-grid-tree plugin but when I render a tree whose info come from an action in JSON format, I have some troubles.
As I want more info from my action for another purposes, my action return not only tree nodes info, but other regarding as operation ACK, and so on...
That's an example of my action result:
{"JSON":"success", "nodes":[{id":"001", "children":null,"data":{"title":"First element "}, "icon" : null,....
So in my tree tag I try to tell the plugin to retrieve info from "nodes" property inside the action's response using "rootNode" property, in this way:
<sjt:tree
href="%{testJSONTreeAction}"
id="testTreeWithCheckbox"
rootNode="nodes"
childCollectionProperty="children"
....
but it doesn't work.
The only way it runs fine is if my response returns just the info about my tree as follows:
[{"attr":{"id":"001"},"children":null,"data":{"title":"First element"}...
I means, just the node information.
Of course I could manage formatting the response as above, but I wonder what is this attribute for. Other tags like grid tags has an attribute for this (gridModel) and works fine, but I can't find it in tree tags docs.
I've seen some related bugs like here but they are regarding old versions and I'm trying the last release of the plugin, 3.5.1.
Thanks in advance,

Animating JSON data?

Dumb question time. I was trying to integrate my JSON data with a flipbook plugin, using a Mustache templating system. Needless to say, this wasn't working at all.
I'm a jQuery noobie, so is there any easy way to bind and animate the JSON data to/with a plugin (with or without the Mustache tags)??
From your question it is a bit hard to deduce what you want, but I feel you got already all the pieces together. First the example you have been linking to in a comment: https://github.com/blasten/turn.js/wiki/Making-pages-dynamically-with-Ajax
This fetches not yet loaded pages via Ajax, and the sample code assumes the Ajax call gets HTML back from the server, as can be seen in the code snippet from there (after adding a missing '}':
$.ajax({url: "app?method=get-page-content&page="+page})
.done(function(data) {
element.html(data);
});
Here the done function processes the data it got back from the server by straight injecting it into the element, which is expected to contain the current page.
I assume next that you do have a server side method, but that method returns JSON instead. Let me assume for the moment that it returns the following structure:
{ "title" : "the title of page N",
"text" : "here is some text for the page N." }
The next thing is to render this JSON into into html in the done funktion, before inserting the result into the page. Looking at the short tutorial on the README.md this might look like:
$.ajax({url: "app?method=get-page-content&page="+page})
.done(function(data) {
var pageHtml = Mustache.render("<h2>{{title}}</h2><p>{{text}}</p>", data);
element.html(pageHtml);
});
If the server returns the proper data you should now see a
<h2>the title of page N</h2><p>here is some text for the page N.</p>
appear on the page.