This project is read-only.

Linking in custom content types

Jan 24, 2011 at 9:27 PM

In my custom item type I'd like to include a hyperlink, but there's no built-in item for it that I can see.  It should support title, link, alt, and target.  Am I just missing something or is this a need?  Maybe I'll put one together if there isn't one yet.

Jan 24, 2011 at 10:13 PM

There are Html extensions to create action links and route links, but if you just want to render a simple link, there are pretty much no good reasons to go through a helper. Why not just write the link into your markup?

Jan 24, 2011 at 11:02 PM

I'm thinking of a Hyperlink column type like in Sharepoint.  I want it to be more than just an inline link.  It's a structured part of the content item.  Think of the Book Review content type in the Orchard documentation.  Maybe you want to include the link to the book on Amazon, or to the author/book's official site.  Also, in terms of presentation, I might want to present my list view as a grid (again, like Sharepoint), with the URL as its own column.

Jan 24, 2011 at 11:38 PM

I see, sorry for the misunderstanding. You should probably create a new field type, following this tutorial:

Or a part, depending on exactly the use case. If you decide to do a part, read this tutorial instead:

To understand parts and fields, you can read this:

Jan 25, 2011 at 6:34 PM

I create a Hyperlink using the samples and guides.  It seems to work, but there are a few aspects that work without my fulling understanding them.  Would you be willing to take a quick look at it and make sure I didn't do anything wrong/stupid?


Jan 25, 2011 at 6:47 PM

You don't seem to have any settings at all so I'm not sure why you'd have the files for them.

The stylesheet looks like it's overriding general stuff. Also, why is it deep in editor templates?

Your display template looks like it will produce lots of unnecessary line breaks that you might want to minimize.

Otherwise looks fine to me.

Jan 25, 2011 at 7:06 PM

Thanks for reviewing so quickly!  It's copied from the DateTimeField so I didn't delete any of the files.  I'll remove the settings stuff to avoid confusion.  The stylesheet isn't actually being used, so I can delete that too.  For the display template, are you saying that I should eliminate the line breaks in the source, even if that affects source code readability, or something else?

Jan 25, 2011 at 7:23 PM

Yes, that's what I'm saying about line breaks. Actually there are ways you can keep it fairly readable, but in the end what the HTML looks like is important I think.