Hi
I have a Slide media type with custom properties including a content picker. I am able to pick up all the other custom properties using @item.Value(), but I am unable to get the content picker url to work the link goes to a 404 page. My code is below
Doing this out of my head, but if you look at the URL that gets returned from @item.Value("slideLink"), it will probably be the Model instead of the URL?
Perhaps, depended on the Model you get returned (which depends on your configuration for the contentpicker) you'd need something like this?
I assume you have ContentPicker set to only 1 product being able to be selected? If not, you could have a List of products to be returned, instead of a single 'products' option.
Hi
It's a compilation error public_html\Views\home.cshtml(20,81): error CS1503: Argument 1: cannot convert from 'method group' to 'object'
The content picker is for the products page with the listing, but I want the user to be able to pick any page to link it to. It is for a slider rather than a single product.
I'm afraid that throws an error too:
public_html\Views\home.cshtml(20,104): error CS1061: 'object' does not contain a definition for 'First' and no accessible extension method 'First' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Not too sure on the how and why this is needed here, but most likely having to do with that the system doesn't know what type of content is being returned.
In my code I now enforce it to be of "IPublishedContent", so the URL method is applicable here.
That doesn't work either it throws the same error CS1503: Argument 1: cannot convert from 'method group' to 'object'. I tried with and without additional brackets.
Using content picker on media type
Hi I have a Slide media type with custom properties including a content picker. I am able to pick up all the other custom properties using @item.Value(), but I am unable to get the content picker url to work the link goes to a 404 page. My code is below
What am I doing wrong? Please help
Thanks in advance Nat
Doing this out of my head, but if you look at the URL that gets returned from @item.Value("slideLink"), it will probably be the Model instead of the URL?
Perhaps, depended on the Model you get returned (which depends on your configuration for the contentpicker) you'd need something like this?
@item.Value
Hi Ambert
Thanks so much for your reply
returns http://mysite/Umbraco.Web.PublishedModels.Products
I already tried it throws an error.
Best wishes Nat
What is the error that gets thrown?
I assume you have ContentPicker set to only 1 product being able to be selected? If not, you could have a List of products to be returned, instead of a single 'products' option.
Hi It's a compilation error public_html\Views\home.cshtml(20,81): error CS1503: Argument 1: cannot convert from 'method group' to 'object' The content picker is for the products page with the listing, but I want the user to be able to pick any page to link it to. It is for a slider rather than a single product.
Thanks for your help so far.
So I think you get a list of objects returned, instead of a single item.
Just to try, you could do:
@item.Value("sideLink").First().Url
If that works, it means that you get multiple objects returned, and it can't get the .Url of a list of objects ;-)
I'm afraid that throws an error too: public_html\Views\home.cshtml(20,104): error CS1061: 'object' does not contain a definition for 'First' and no accessible extension method 'First' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
Ah I misinterpreted it a bit, my bad, this will most likely help:
Try the following:
Not too sure on the how and why this is needed here, but most likely having to do with that the system doesn't know what type of content is being returned.
In my code I now enforce it to be of "IPublishedContent", so the URL method is applicable here.
That doesn't work either it throws the same error CS1503: Argument 1: cannot convert from 'method group' to 'object'. I tried with and without additional brackets.
And when you try this aswell?
I had it giving the correct value with both of the options added.
Hi Ambert
I managed to fix it with this code:
but three links appear on one slide/image rather than one link per slide/image
Thanks again Best wishes Natasha
But thats logical right?
You have 1 slide, and a contentpicker on that slide where you select three different links ;-)
Better to restrict the contentpicker to one link.
Then in the content, add a contentpicker, and select 3 different slides. Fixed!
is working on a reply...