rasmusjp / umbraco-multi-url-picker Goto Github PK
View Code? Open in Web Editor NEWMulti Url Picker for Umbraco 7
License: MIT License
Multi Url Picker for Umbraco 7
License: MIT License
In my case i would need to access umbracoUrlAlias
var multiUrlPicker = Model.Content.GetPropertyValue("MyProperty", true) does not appear to do anything??? Thoughts?
When I deploy some content with a Multi Url Picker in Umbraco.com, the links in ie. staging ends up being wrong.
I think it is because Multi Url Picker stores id's and they can be different from environment to environment.
Is it possible to use GUIDs instead?
Would it be possible to add a File Upload option in addition to being able to pick from the media section? I know the picker allows you to upload straight into the media section, but there are cases when you don't want the item available in the media section. You may recall the old uComponents Url Picker had this option.
Thanks!
With the latest version of the Multi-Url Picker the datatype is broken if I use the NuGet version of the package since that adds a package.manifest file. If I remove it, things start to work again.
If I use the Umbraco package), the package.manifest is not created and everything works fine.
Is the package.manifest file not needed anymore?
I have posted at archetype forum http://our.umbraco.org/projects/backoffice-extensions/archetype/sound-off!/56104-How-to-get-Multi-Url-Picker-data-from-Archetype
but thought I should ask the Multi Url Picker developer too, if Im missing obvious;
Need some guidance on how to use the Multi Url Picker from Archetype property in a Partial.
I have created a simple Archetype with a textstring and the 'Multi Url Picker' property.
If I try to code sample given in multi url picker page, it gives YSOD with < MultiUrls > does not exist. I did include @using RJP.MultiUrlPicker; at the top of the page but still the same error.
I cant seem to figure out how to make this work seamlessly with Archetype. In a (very) hacky way I can get the values with; (configured multi url picker with min 1 and max 1 links, so just getting 1 link for now)
@using Newtonsoft.Json;
@foreach (var fieldset in Model.Content.GetPropertyValue("slidelinks")) {
var thelinkJSON = fieldset.GetValue("link");
dynamic thelink = JsonConvert.DeserializeObject(thelinkJSON);
}
If someone can shed some light on how to properly use Multi Url Picker with Archetype would greatly appreciate.
I have tried to use the multi url picker as a link
property in a LeBlender grid editor.
However I can't really make it work with cast to the strongly typed object.
I have tried with both a Multi Url Picker and Single Url Picker (max items = 1).
Inside LeBlender grid editor.
@if (Model.Items != null && Model.Items.Any())
{
var item = Model.Items.First();
// both of these return null
var link1 = item.GetValue<IEnumerable<Link>>("link");
var link2 = item.GetValue<Link>("link");
}
If I use LeBlenders GetRawValue
method I get the raw json, but when I deserialize this to either IEnumerable<Link>
or Link
it returns Unexpected character encountered while parsing value: l. Path '', line 0, position 0.
var link = item.GetRawValue("link")
var linkPage = !string.IsNullOrWhiteSpace(link) ? JsonConvert.DeserializeObject<Link>("link") : null;
The raw json value looks like this:
[ { "id": "1076", "name": "Forside", "udi": "umb://document/48a5922997804cb5929074151348071a", "url": "/", "icon": "icon-home", "published": true } ]
If I re-use the variable from GetRawValue
:
var link = item.GetRawValue("link");
var linkPage = !string.IsNullOrWhiteSpace(link) ? JsonConvert.DeserializeObject<Link>(link) : null;
then I get this error:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'RJP.MultiUrlPicker.Models.Link' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array. Path '', line 1, position 1.
i am close, but not really experienced with Models Builder, can you provide me a bit more of a full example with nested content in mind?
What's the backend username and password for the TestSite project?
Hey,
when introducing many links picked in picker, i see:
System.Data.SqlClient.SqlException: String or binary data would be truncated.
The statement has been terminated.
when publishing page.
could it be a wrong database field type selected?
Hi @rasmusjp,
I've found a bug:
When I set Min number of items
and Max number of items
to 1
and I try to add a non-content link (just link and page title) I get an error: You need to add at least 0 more item(s)
.
I've looked in the code and on line 77
in MultiUrlPicker.js
and I've found that $scope.watch
is not registering any change when there are 0 items or 1 item (non-content link, which doesn't have an id), since the function assigned to the watchExpression
is returning an empty string in both cases.
I've changed line 77 to:
//return _.map($scope.renderModel, function ( i ) { return i.id }).join()
return $scope.renderModel.length;
and it appears to be working now.
Great addon btw ๐
Given I have media with ID 3 and path of "/media/123/maidenname.docx"
Given I have picked media item 3.
Given I replace the file of media ID 3 I get a path of "/media/124/marriedname.docx"
When I edit the place where item 3 was picked, and click 'select' again
Then the link becomes an external link, and the URL used is "/media/123/maidenname.docx"
Note: If I do not edit/save this picked item then the link remains unbroken since it determines the url from media ID 3 at run-time.
I consider this a somewhat rare corner case, but it should be noted.
Aside: I have a thumbnail upload for media of type file... in this case the "Link to document" field shows the thumbnail URL, but the correct URL is shown to the user... in this case when the record is edited and 'select' is clicked without re-picking the media then the links now link to the thumbnail not the PDF, and it is now an 'external' link.
Note: editing the link (by opening click select) always converts it to an external link regardless of whether the media item has been modified.
Hi,
My client as ask me to pass on a feature request: Can you add an "External link" button next to the "Link to file" button to make the process of adding an external link more explicit?
Currently, once you've clicked on the content tree you have to close & re-open the dialog to enter an external link.
Thanks,
Antony
Given Content or Media named "Maiden Name"
Given I have picked "Maiden Name" in an RJP picker (using Link to file
if Media)
Given I have not specified a custom page title.
When I rename "Maiden Name" to "Married Name"
Then existing links do not update to "Married Name"
This could be considered a bug.
If we change the scenario slightly and say:
Given we specified the page title as "Mum"
Then keeping "Mum" is a feature (no pun intended) and I would 'not' consider this a bug.
Ideally both these scenarios could be catered to, and here's how I think it could be done.
By default picking Content or Media does not fill in the Page Title field, but leaves it blank...
In order not to confuse the user the placeholder text should change to the picked item's Node Name, in this case "Maiden Name" (perhaps some additional UI hints or text could be provided if this is not clear enough what is happening)
If the user then over-writes the page title with "Mum" then "Mum" is kept.
Note: this should work the same way for both Content and Media.
This is a weird one and I haven't been able to narrow it down to anything, but on the initial startup request (after an apppool restart) the picker only returns the first item in the list. On a refresh all items are present. We're on 7.6.5 running in Umbraco Cloud.
Hey, thanks a ton for this property editor. The url picker from uComponents was awesome, but as it isn't available for Umbraco 7, this is a great alternative.
I was thinking about making some minor cosmetic changes and wanted to know what you thought.
Nice package!
Would it be possible to add this to as a macro parameter? (I'm using macro's as widgets on a site)
I've tried to add "isParameterEditor: true" to package.manifest, and so far so good, it does work.
But when using in a macro container, and a link is selected, the umbraco panel is closed before I'm able to save the macro parameters:
Thanks!
Hi!
Would it be possible to add more logging to the log entry
"MultiUrlPicker value converter skipped a link as the node has been upublished/deleted (Id: ###), "
to include where it was skipped? So we can fix the dead link?
Cheers for a good tool.
Hey
Im building a special grid property where i would really like to use your multiurlpicker as my url picker since im using it every where else in the solution.
How could i do this, or can this even be done ?
You can easily add a config option, so the editor only can select images (.jpg, .gif, .png, etc.) from media.
i am trying to only loop or get count of content links that have a specific property value... lets say audience. How would i craft a lambda expression to get a count of those only? any help would be great.
Hi there @rasmusjp. Nice plugin ๐
The Nuget install fails to include package.manifest and references to assemblies.
When I went to build the courier project with the lates version of courier, the interfsace to courier seems to have changed. In MultiUrlPickerDataResolverProvider.cs change
link.id = PersistenceManager.Default.GetUniqueId(
for
link.id = ExecutionContext.DatabasePersistence.GetUniqueId(
I currently have a limited set of users that I don't want them to be able to upload to the media section, due to naming conventions, folder destination etc etc.
I still want them to have the ability to choose a media item from this section, but it keeps prompting for a username and password.
Hi,
It looks like in Umbraco 7.1.1 I can't choose a PDF file from the Media folder through your picker.
Is this something you are looking at?
Kind regards,
Iulia
Hi,
I would not consider this an issues, I am just sure there is a better way of doing this.
I want to be able to tell what I am being passed, External link, internal link or link to a media item. This is what I am using, umbraco 7.1.4 MVC.
var multiUrlPickerDyn = CurrentPage.tilesLink;
if (multiUrlPickerDyn.Any())
{
var dType = "";
foreach (var item in multiUrlPickerDyn)
{
if (@item.Id != null) {
if (String.IsNullOrEmpty(Umbraco.Content(@item.Id).DocumentTypeAlias)) {
var iType = Umbraco.Media(@item.Id).ContentType;
dType = iType.Alias;
node = Umbraco.Media(@item.Id);
} else {
dType = Umbraco.Content(@item.Id).DocumentTypeAlias;
node = Umbraco.Content(@item.Id);
}
} else {
dType = "ExternalLink";
}
}
}
Now I am not the worlds best coder, but this is not exactly pretty even by my standards...
Is there a better way of doing this? I am hoping you are going say there is something built-in for this. I couldn't find any more detailed docs to see though.
Your help is much appreciated.
Loving the datatype though, thanks.
Stephen
The internal multi URL picker is already more powerful (restrict by document type and/or content path); so I only want to use this in a case where I definitely know I need external links, and at least some of those cases are external-only (there is a different document type or property for internal).
A customer of ours managed to bring the "value" of the property in a state where it was similar to this:
value: [
{id:1234},
null,
{id:1234},
]
So somehow one of the items in the array was null.
This cause two things:
The datatype failed, because it tried to access the id property of a null object
The frontend failed because the value converter tried ti access properties on a null json object.
I have not been able to reproduce how the null got there in the first place, but it would be nice if the two scenarios above where more null tolerant :)
I fixed the datatype by adding a null check around the building of the renderModel:
if( $scope.model.value ) {
_.each($scope.model.value, function( item, i ) {
if (item !== undefined && item !== null) { //Check for null
$scope.renderModel.push(new Link(item));
if( item.id ) {
(item.isMedia ? mediaIds : documentIds).push( item.id );
}
}
});
}
In Umbraco 7.4, when added to a Doctype, the "Add" button doesn't work at all - if you click it, the right-pane of the content node resets to show the Content section main dashboard ("Get Started" tab, etc.).
In addition, this causes the loss of any unsaved property data in the node.
First, a big thanks for this project - I use it on nearly every site I develop and it's always worked great.
I only have one tiny issue, and that is that (by default) MultiUrlPicker creates a lot of warnings in the Umbraco trace log when it skips a node that no longer exist. Example from my tracelog file:
[T164/D2] MultiUrlPicker value converter skipped a link as the node has been upublished/deleted (Id: 2424)
For a large site the number of log entries can become overwhelming. For instance, I'm looking at one site I built (that has a lot of nodes) and the log file for just one day has over 7,000 instances of this warning being logged.
Would it be possible to disable warnings or have a way of configuring it so these warning are disabled? I can understand they might be useful for debugging, but for most people they aren't of any use. Thanks!
Trying to use the Multi Url Picker inside an Archetype data type. Here is my Razor code to get the URL:
var multiUrlPicker = fieldset.GetValue<MultiUrls>("buttonURL");
if (multiUrlPicker.Any())
{
foreach (var item in multiUrlPicker)
{
<p><a href="@item.Url" class="btn btn-primary btn-lg">@fieldset.GetValue("buttonText")</a></p>
}
}
When I view the page, I get this system error:
Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JArray'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'Newtonsoft.Json.Linq.JValue' to type 'Newtonsoft.Json.Linq.JArray'.
Source Error:
Line 79: @if (fieldset.HasValue("buttonURL"))
Line 80: {
Line 81: var multiUrlPicker = fieldset.GetValue("buttonURL");
Line 82: if (multiUrlPicker.Any())
Line 83: {
Is this something I'm doing wrong, or is it incompatible with 7.4.x?
Hi @rasmusjp
Great package by the way. Umbraco should make your picker as a new standard in the cms. Its absolutely fantastic.
What would make it even more awesome is a single box for querystring parameters to add onto the url, wether its an external or internal link. This allows for flexibility. Maybe a add parameter button which allows you to add multiple key pair values
I installed package, but can't make it work, when creating new DataType, not on the list, cleared cache, tried different browsers, could you help?
Currently using this and we now get an "undefined" error in Umbraco when a user tries to save a page where a MultiUrlPicker has more than 100 items.
Would it be possible to remove nodes from the tree, that doesn't have a template attached ?
It could just be a checkbox when configuring the datatype. (Hide nodes without a template true/false)
Can there be an option for each URL to add additional attributes?
At the moment I am thinking of nofollow, ideally a checkbox for this specific attribute would be good.
The description of the plugin says that media is supported, but the plugin doesn't provide access to the media library to pick from.
It allows you to search and find nodes as expected, but doesn't return anything when retrieved in razor.
Hi,
I hit this error when adding more than 9 links to a picker.
I think the json property data is being saved in the dataNvarchar column which has a max length of 500 chars. The RTE for example saves its content in the dataNtext column of cmsPropertyData which is unbounded.
I'll have a poke about and see how to save the data in the other column from angular
On my server version of a project the following code works:
foreach (var item2 in multiUrlPicker)
{
@item2.Name
}
However on my local version I can only retrieve properties with lower case, e.g.
<a href="@item2.url" target="@item2.target" class="btn-default btn-paly">@item2.name</a>
Using Umbraco 7.2.6.
Media items should also save their ID into the JSON data in the same way as content.
Without this the data could be stale as the media items could have a new upload with a new file name or even deleted and there is no way to check.
In the changelog, i read "New data types with max number of items set to 1 will return a single Link or null.
Existing data types will continue to return IEnumerable."
How can I use the "New data type", instead of the "Existing data type"? I see no difference in the DataType property editor naming (this is Multi Url Picker).
Or should I read Existing vs New as when document types already have a Multi Url Picker property defined vs when one is newly added?
The multi url picker isn't working with the Doc Type Grid Editor Package https://our.umbraco.org/projects/backoffice-extensions/doc-type-grid-editor
The problem is that when you select or enter an Url in the picker it closes the current dialog but it also closes the Doc Type Grid Editor dialog.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.