How to show selected node on content picker to front page - umbraco

I want to create a selection of banner with Content Picker' to select node to use other banner. http://screencast.com/t/3gb6TeAe
Now I wonder how to show the selected banner on Content Picker and show it in front page. Any idea to make it in easy way.
I have tried already to get the Url of selected node.
var nodeId = Model.Content.GetPropertyValue("selectBanner");
var node = Umbraco.TypedContent(nodeId);
#node.Name

If my understanding is correct you first need to get the banner node:
// This gets the node selected by your content picker
var bannerNode = Umbraco.TypedContent(Model.Content.GetPropertyValue<int>("selectBanner"));
You then need to get the image specified on the banner node:
// This gets you the image/media set on the banner nodes media picker property
var img = Umbraco.Media(bannerNode.GetPropertyValue("mediaPickerPropertyAlias")).Url
You can then access either the bannerNode url:
#bannerNode.Url
or the image specified on the banner node:
#img.Url

From what I can understand you have a Media Picker in your Banner document type. So you need to access banners image Url... you can do following
var node = Model.Content; // Your content of type banner
var imgUrl = Umbraco.Media(node.GetPropertyValue("selectBanner")).Url // getting property for image and then its url
#node.Name
or if you want to show just image
<img src="#imgUrl"/>

Related

PDF.js - How can I get currently visible page(s)?

At an event that occurs after the PDF is loaded I load in drawings to put on the canvas. I need to know which page(s) are currently rendered so as to get the correct drawings.
How can I detect which page(s) are currently rendered (ie, visible, possibly more than one because of user scrolling between pages)?
You can use the following code to achieve it:
function getCurrentPage() {
let pdfViewer = PDFViewerApplication.pdfViewer;
let pageIndex = pdfViewer.currentPageNumber - 1;
let pageView = pdfViewer.getPageView(pageIndex); //Give you the pageView object
let domElement = pdfViewer.getPageView(0).div; // Give you the reference to page dom element
return pageView;
}
Hope this helps

AppMaker and picker widget - uploading to a specific folder

I'm trying to have a button to allow users to upload a file, into a specific folder. I tried to follow other advise, and add this hook to
onPickerInit:
var uploadView = new google.picker.DocsUploadView()
uploadView.setParent('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); // test folder
pickerBuilder.addView(uploadView);
I've set the MULTISELECT_ENABLED feature (without it, the destination folder is not respected), and I can in fact now upload the files where they belong. Yay!
HOWEVER: The picker widget now has two upload tabs. The first one just does the regular upload into the drive main folder, the second tab does the right thing. My guess is that appmaker contstructs the first upload tab behind the curtains and there is no feature to disable this.
This is obviously fairly quirky and hardly usable. My questions are:
1) are there (possibly undocumented) API calls in the pickerbuilder to remove the original upload view?
2) Is it possible to respect the destination folder even is the MULTISELECT feature is off ?
Many thanks in advance for any pragmatic solutions!
EDIT 07/28/2020
Due to the constant changes in drive picker, this code aims for a more permanent solution:
var folderId = "10fYS3l32R6gk79POOSS8X_Vbsz7vqzRWX"; //the desired folder id
var prps = [];
for(var prop in pickerBuilder){
var value = pickerBuilder[prop];
if(!!value){
if(typeof(value)==="object"){
var proto = value.__proto__; //jshint ignore: line
if(!!proto["addLabel"] && !!proto["addView"]){
prps.push(prop);
for(var key in value){
var target = value[key];
var type = Object.prototype.toString.call(target);
if(type === "[object Array]"){
prps.push(key);
for(var key in target[0]){
var value = target[0][key];
if(typeof(value)==="object"){
prps.push(key);
}
}
for(var key in target[0]){
var value = target[0][key];
if(typeof(value)==="string") {
prps.push(key);
}
}
}
}
}
}
}
}
var views = pickerBuilder[prps[0]][prps[1]];
for(var i=0; i<views.length; i++){
var view = views[i];
if(view[prps[3]] === "upload"){
view[prps[2]].parent = folderId;
}
}
EDIT 06/29/2020
There has been another change in the Drive picker API. To make this work please change what you have to:
var folderId = "10fYS3l32R6gk79POOSS8X_Vbsz7vqzRWX"; //the desired folder id
pickerBuilder.rw.kf["0"].Ta.parent = folderId;
EDIT 05/26/2020
There has been another change in the Drive picker API. To make this work please change what you have to:
var folderId = "10fYS3l32R6gk79POOSS8X_Vbsz7vqzRWX"; //the desired folder id
pickerBuilder.xw.jf["0"].Ta.parent = folderId;
EDIT 02/17/2020
There has been a change in the Drive picker API. To make this work please change what you have to:
var folderId = "10fYS3l32R6gk79POOSS8X_Vbsz7vqzRWX"; //the desired folder id
pickerBuilder.mw.$e["0"].Ra.parent = folderId;
To answer your questions directly:
1.) YES
2.) YES
Now, let's dig a little bit into what's happening under the hood. You are right:
My guess is that appmaker contstructs the first upload tab behind the curtains and there is no feature to disable this.
However, we can manipulate the object. So instead of creating a new picker view, let's simply configure the default one to upload the files to the folder you want. We can achieve that by doing the following:
1.) After you insert a Drive Picker into your UI, make sure the Drive Picker Properties are all empty:
2.) Next, go to the event handlers and click on the onPickerInit event handler. Type in this code:
var folderId = "10fYS3l32R6gk79POOSS8X_Vbsz7vqzRWX"; //the desired folder id
pickerBuilder.SW.Vq["0"].mc.parent = folderId;
In summary, I've come to the conclusion that the property SW contains the array of drive views, which are saved under the property Vq. Vq["0"] is the first view in the array of views and the mc property contains the features; hence parent = folderId.

Issue with twitter Profile image using Titanium

I am newbie to titanium, I am learning JSon Parsing with titanium. I am accessing tweets for a specific screen name along with his/her profile picture. It is working well as concern to tweets but not showing the profile picture of that tweet.
My Tweet.js file is :
// Create variable "win" to refer to current window
var win = Titanium.UI.currentWindow;
// Function loadTweets()
function loadTweets()
{
// Empty array "rowData" for our tableview
var rowData = [];
var avatar;
// Create our HTTP Client and name it "loader"
var loader = Titanium.Network.createHTTPClient();
// Sets the HTTP request method, and the URL to get data from
loader.open("GET","http://api.twitter.com/1/statuses/user_timeline.json?screen_name=SenchaTouch");
// Runs the function when the data is ready for us to process
loader.onload = function()
{
var tweets = eval('('+this.responseText+')');
alert(tweets);
for (var i = 0; i < tweets.length; i++)
{
var tweet = tweets[i].text; // The tweet message
var user = tweets[i].user.screen_name; // The screen name of the user
avatar = tweets[i].user.profile_image_url; // The profile image
// Create a row and set its height to auto
var row = Titanium.UI.createTableViewRow({height:'auto'});
// Create the view that will contain the text and avatar
var post_view = Titanium.UI.createView({
height:'auto',
layout:'vertical',
top:5,
right:5,
bottom:5,
left:5
});
// Create image view to hold profile pic
var av_image = Titanium.UI.createImageView({
url:'KS_nav_ui.png', // the image for the image view
top:0,
left:0,
height:48,
width:48
});
post_view.add(av_image);
// Create the label to hold the screen name
var user_lbl = Titanium.UI.createLabel({
text:user,
left:54,
width:120,
top:-48,
bottom:2,
height:16,
textAlign:'left',
color:'#444444',
font:{fontFamily:'Trebuchet MS',fontSize:14,fontWeight:'bold'}
});
post_view.add(user_lbl);
// Create the label to hold the tweet message
var tweet_lbl = Titanium.UI.createLabel({
text:tweet,
left:54,
top:0,
bottom:2,
height:'auto',
width:236,
textAlign:'left',
font:{fontSize:14}
});
post_view.add(tweet_lbl);
// Add the post view to the row
row.add(post_view);
// Give each row a class name
row.className = "item"+i;
// Add row to the rowData array
rowData[i] = row;
}
// Create the table view and set its data source to "rowData" array
var tableView = Titanium.UI.createTableView({data:rowData});
//Add the table view to the window
win.add(tableView);
};
// Send the HTTP request
loader.send();
}
loadTweets();
// Can any find out the flaw ?? Any help would be appreciated.
Thanking in advance :)
At last found it .. The problem was in code. I just use url property in the image view instead of image property. Replacing the image property with that of url has done the trick.
url: avatar, // It should not be used .. It is not working
image: avatar, // It is working very well..

could not be able to work with list control in flex 4.5

I want to be selected that new Item in list when I give new value to dataProvider but it selects the item that was firstly selected, and how to make that selected permanently on App start up.
You if want to select the list item after added to dataProvider. Probably you follow this
list.selectedIndex = list.dataProvider.length -1;
Sometimes if you added at desired position like
list.dataProvider.setItemAt(obj,2);
list.selectedIndex = 2
If you want to selected item permanently on App start up.(Make sure that your array collections bind-able to list)
public function onCreationComplete(event:FlexEvent):void
{
callLater(function():void
{
list.selectedIndex = list.dataProvider.length -1;
list.ensureIndexIsVisible(list.selectedIndex); // Viewport
});
}

How to display Picker with one item using Playbook's QNX

I've got a QNX Picker control that isn't displaying the selected values when there's only one item in the picker. For example:
import qnx.ui.picker.Picker;
var pick:Picker = new Picker();
var arr:Array = [{label: "hi!"}];
pick.dataProvider = new DataProvider([new DataProvider(arr)]);
pick.selectedIndices = [0];
addChild(pick);
The result is a blank picker. Maybe I'm doing something wrong. When there are 2 items in the arr Array, the picker actually shows the selected Indices.
How do I get the picker to display the selected item when there is only 1 item to choose from?
I'm using Burrito, with Playbook SDK 0.9.3.
Thanks in advanced!
I assume that you are going to populate the picker at some point in order to actually use it, so you could just use your existing array and add a blank entry:
var arr:Array = [{label: "hi!"}, {label: ""}];
and then pop the array to remove the blank item before you add new data.

Resources