This project is read-only.

How to create a link to details view

Topics: Customizing Orchard, General
Jun 3, 2013 at 11:26 AM
Hi in my summary view I have an image which I would like to make a clickable link to the details view. I am unsure how to do this as each item in my summary view is part of a list. Any ideas please?

Thanks, Kirsty
Jun 3, 2013 at 4:32 PM
Create a view for that content item's type Summary display type, and render the link there using Url.ItemDisplayUrl, e.g.
<a href="@Url.ItemDisplayUrl((IContent)Model.ContentItem)"><img src="..." /></a>
Jun 4, 2013 at 1:13 PM
Hi sfmskywalker

I tried this but I get the following error Compiler Error Message: CS0246: The type or namespace name 'IContent' could not be found (are you missing a using directive or an assembly reference?)

I am using the following template - Fields.MediaPicker-SummaryImage-url-main-property-page.cshtml

Please can you help?

Thank you :)
Jun 4, 2013 at 3:51 PM
Sure. Make sure to import the proper namespace:
@using Orchard.ContentManagement;

<a href="@Url.ItemDisplayUrl((IContent)Model.ContentItem)"><img src="..." /></a>
Jun 18, 2013 at 12:27 PM
Thanks yet again sfmskywalker, I have now got this to work :)