Using Media Profiles in Query Layout

Topics: Administration, Core, General
Feb 17, 2014 at 9:16 PM
Edited Feb 17, 2014 at 9:21 PM
I'm still learning my way round Orchard (v1.7) and finding it very flexible although not always easy! I am an experienced c# and asp.net webforms programmer but am still very new to Orchard and MVC - as such I'm trying to avoid too much coding and work within Orchard's out of the box capabilities instead.

I'm working with Queries and Projections to achieve a lot of the layouts and functionality I need but was wondering - is it possible to use a Media Profile within the Query layout 'Rewrite Results' field? I'm already successfully using the List Layout Rewrite Results field to output images into a specific layout but the addition of the Media Profile would be very helpful. So far my attempts to use a Media Profile here haven't worked - I simply get a blank output.

Here's a screenshot of what I've tried:
Image

I'd appreciate any advice - if it's simply not possible, I'll have to try something else.

Thanks!
Feb 20, 2014 at 12:15 PM
Hi guys - sorry to bump this but can anyone help? Have I posted in the wrong place?

Even a 'You're doing it all wrong' would be helpful ;-) I have googled the problem extensively and haven't found anything.
Developer
Feb 20, 2014 at 3:37 PM
You are including a Razor + C# expression on the Rewrite text field. Although I haven't looked at its implementation, I am betting that it will not get executed. I assume the field is tokenized though, so perhaps there's a MediaUrl token.
If not, you could probably write one such token provider, but it is probably easier to override some views in your theme and customize the rendering there.
Feb 20, 2014 at 3:51 PM
Thanks so much for the response - I was kinda sceptical whether that syntax would work here but I did wonder if there might be a tokenised equivalent I could use.

If not, like you say, I'll just need to bite the bullet and override the view. I haven't attempted this yet but there seems to be lots of information out there.

Thanks again.
Aug 12, 2014 at 7:39 PM
Did you ever resolve this issue? I am trying to do a rewrite on a Media/Document query and reproduce the download link but can't figure out how to access MediaUrl
Aug 12, 2014 at 9:09 PM
I took a different approach in the end as Media Profiles aren't supported in this context. I'm away from my code at the moment but if it'll help, l can look up the details of what I did. Let me know.