3

I'm using Joomla's K2 content component. There's a bunch of reasons we're using it, but one is to provide a nice way for the client to attach files to some of their articles. This works really well and the client is very happy with it.

However, they have also now asked if they can have an "attachment" which is actually a link to a file on an external site. The external site is a partner organisation that provides some of their documents; they want to hot link directly to the partner's files because the files are updated fairly often, and they don't want the overhead of having to re-load them every time.

This request is, of course, quite easy to achieve if I just add a link directly in the article text, but the client would like it if the items were listed as K2 attachments in the same way as they currently do for their internal files.

So is it possible to have external files as K2 attachments? Or will I just have to use plain old links?

Thanks.

2

It can be possible with a custom field.

The way I did something kinda similar, for fetching Facebook Albums:
I created a custom k2 field and an override for the default.php template file of the k2 item in backend.

In the override I added my custom code to fetch the external data and then using AJAX I converted the custom field (selected by its unique id) to a dropdown list, that is loading the above data.

So in your case, if you follow the same approach as mine, you will need to be able to call and fetch remotely the external files from the other site. How to access them, is something you need to work it out, in accordance with the available options given by the resource site.

After doing so, you can make them available to the backend via the custom field and present them the way you want (e.g as dropdown or checkboxes).

  • Thanks for the answer. I'll check it out and see how I get on. :-) – Simba Dec 7 '15 at 14:13
1

I assume what the client is after specifically is an icon and the file to open/download when clicked on. And this to be added easily by him.

Why wouldn't you simply create a CSS class for these external links which places a copy of the attachment icon before the link?

Then show the client how to add an external link that opens in a new target window and how to include the CSS class in the link.

Certainly not as elegant as a custom coded solution, but much easier to implement and unless you put in some decent coding time, probably a lot more flexible.

  • Hi Garth. Thanks. Yes, this is basically my fall-back solution in case I don't find what I'm looking for. – Simba Dec 7 '15 at 17:25
0

Both the answers given were useful and I've upvoted them both.

However, after working through the options and discussing the requirements in more detail with the client, we've reached an alternative solution.

What we've done is to install the Weblinks plugin. (this was core in earlier versions of Joomla but is now separated and can be installed from the JED).

Weblinks allows us to have categorised links to external resources, along with a description for each. It meets the requirement pretty much exactly.

There are a couple of minor issues down to the fact that it's a separate plugin from the rest of the content, but the client is happy to live with them. The biggest of these issues is that Weblinks entries aren't included in search results. But this is mitigated by the fact that weblink category pages have their own search/filter function.

  • 1
    Pretty sure Weblinks comes with its own search plugin that extends search, so you should be able to include in general search results. – BodgeIT Dec 10 '15 at 17:54
  • 1
    I'm glad that you found the appropriate solution. Neither of us included Weblinks in our answer because it is standard to Joomla (though it is now a separate plugin) and the inference in the article was that you wished for the client to be able to link an external site from within an article. Obviously, that requirement changed. – garth Dec 11 '15 at 6:01
  • @garth, yeah, things evolved as I spoke with the client and showed them various options. The weblinks idea didn't occur to me at first as they were focussing on wanting it to be within the same admi UI as their other categories, but once they saw it in action they were swayed by it; it's pretty easy to use and does what they want. Thanks for your input though, and @FFrewin; both were very helpful in coming to a final conclusion, and I can easily see that others with similar needs might very well go with one of your solutions. – Simba Dec 11 '15 at 10:58

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.