7

I am looking for a systematic way to deal with links in Drupal, like there is for images. For images, you add image field to content type, then install "Insert" module and you can use Wysiwyg to easily insert the image anywhere inside the node content and still have it "manageable" because it is a field.

I am looking for something similar for links (external and internal), but can't think of any existing method. What I have found is to either use "Links" module and have all links displayed at the bottom of the node (via a field) or use Wysiwyg "Link" button and insert links anywhere, but they are unmanaged.

I am looking for a solution where:

  1. All links would be more easily managed - because they would be kept as fields (most probably "Link" field)
  2. It would be possible to have those links displayed not as a link list at the bottom of the node, but rather in various places inside node content (like images with "Insert" module).
1

I would recommend that you base your solution on the ckeditor_link module. To use this module, you will of course need to be using ckeditor for your wysiwyg editing. If this is not a problem, then users will be able to use a new "Internal Link" URL type when creating links. Typing in the node title of the target will make a link to node/1234, and this link will be transformed into a link to the node's path alias at render time. Now, your internal links will automatically change if you edit the path alias of the node; there is nothing else you need to do to manage them.

For external links, I would make a new node type for external links, and make a landing page for each one. Use a link field on the landing page to hold the external link, and put boilderplate text in your template for that content type. Once you've set this up, you can again use the ckeditor_link module to target your landing page. If you don't like the idea of a landing page and you're a little handy with coding, you could make your own version of ckeditor_link for external links, and modify its input filter to render the URL of the target link instead of the URL of the landing page.

  • We are using tinymce (and cannot change), but I'll check if it would be possible to have something similar in tinymce. – camcam Sep 24 '12 at 12:28
  • As an interim step (until someone writes a link editor plugin for tinymce), if you wanted to require users to enter internal links as node/1234, then you could use the internal links project to convert them back to their aliased path again at render time. See drupal.cocomore.com/blog/… – greg_1_anderson Sep 24 '12 at 15:52
  • Another option that also involves coding would be to look at the links project (drupal.org/project/links). It only has a D6 version, and saves links in its own table rather than putting them in a link field, but does have code to extract links from nodes at node-save time, and does keep a mapping between links and the nodes that they appear in. – greg_1_anderson Sep 24 '12 at 20:42
1

camcam, The best module I found so far is LinkIt, it can be either integrated into TinyMCE or can be used on standalone fields. It does allow for internal vs. external links flexibility on standalone fields, so should solve your issue. Hope this helps.

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.