#blocks that do not have link in CMS should not show link in frontend

1 messages · Page 1 of 1 (latest)

mossy ibex
#

You're seem to be using the Url() property on your BlockList Item

#

oh wait, you have a propety called 'Url' added to it ? So thats why you check for content.Url ?

#

Is the Url a linkpicker?
If so, then you probably should check on content.Url.Url()

#

as content.Url properly returns the type always, hence it always triggers the first option in your if/else

#

You could test if you type @content.Url in front of your if/else, then you'll see what is being checked

icy galleon
icy galleon
mossy ibex
#

Have you tried printing the value the content.Url returns? I guess its a mediapickerproperty then,

Try content.Url.Url()

As you named the mediapicker Url and you need the Url() property of your media item

icy galleon
mossy ibex
#

yes

#

But you need to knowe what content.Url is currently, I THINK its a mediapicker(it looks like it),

So i THINK it should work if you change your first attempt, (the one with the if/else), to:

if(string.isNullOrWhiteSpace(content.Url.Url()))``` it might work
#

however, I would not advice to name your MediaPicker 'Url', as it's not only the Url thats returned, but an entire Media object. I'd recommend to naming it something like 'image' for easier usage

icy galleon
icy galleon
sacred vale
#

Your content is of type IPublishedElement, it doesn't have a url property. You need to use the weakly typed method .Value<>() to get the property value that you need or add a type check to your logic.

mossy ibex