2

Sorry if this question has already been asked.

I'm building a website for a client. In their footer they have several list of links, and I want them to be able to change them (so not hardcoded into the code).

I'm using a "Entries" type for those linklist. It is intuitive but there are two main caveats:

  • They have links like "Blog" that must link to an index of a channel. Unfortuantely, because this is not an entry, it does not appear. I've found an ugly workaround that consists of creating a single "Blog", but this is a bit annoying because there is an additional single appearing for them, and this means that I need to rename the channel to something else (because Blog become already taken by the single).

  • They have some links that point to an external URL (they host their FAQ on ZenDesk, so the FAQ is an external URL). It therefore does not work.

For the last point, I've found a nice plugin called LinkIt (https://github.com/fruitstudios/LinkIt) that nearly tackles the problem, but with one major drawback: contrary to the Entries type, it only allows to add one link (using a matrix feels a bit overkill here and is less intuitive than the Entries stuff).

Did I miss something? I think it would be really good if Craft could have a new field type "URL", that would allow to enter a free URL with a label. It would give much more flexibility to the system.

Thanks!

| improve this question | | | | |
2

Michael,

This is a very common development pattern that we run into. Our primary method of resolving is to create a global set with matrix of links. Using a matrix allows you to extend the matrix item with whatever fields you would need based on the ui, such as an icon class.

Matrix Layout:

Links (link)
│
└─ Link Text (text)
└─ Link Entry (entries, limit 1)
└─ Link URL (text)
└─ Link Target (dropdown, [_self, _blank])

I think that a matrix is a good choice, even considering user experience, because they can be collapsed after setup and it is likely that your user is familiar with them from other areas of the site.

If you don't want to use vanilla Craft you could use the Linkit plugin to add a more robust link field-type. It even lets you set the title, click behavior and works with various types of entries, assets, and custom URLs.

Linkit plugin for Craft https://github.com/fruitstudios/LinkIt

Good luck!

| improve this answer | | | | |
0

Thanks a lot for the answer Michael. I've just tried your idea but unfortunately it's not really simple for my use case. In my footer, each linklist has not only links, but also a title:

enter image description here

What I'm currently doing is a matrix called "Linklists", with only one possible block that accept a list of link AND a title. It makes things super easy for the end user:

enter image description here

Need a new linklist ? Just add one, specify title and links. Boom.

In your idea it would nicely work only if Craft supported matrix of matrix (where the block would be "Linklist", and each linklist would be themselves a matrix with your fields).

Actually, LinkIt nearly solves completely the issue, the only limitation is that it only allows up to one item, and does not allow to create multiple links as the entries field allow.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.