I have a custom content type called Location. A location can have file resources which are text files or pdfs which will be stored on the server. A location can also have links to external websites. The same resource can be associated with more than one location, and a location can have several resources.
I am planning on making a many to many between two custom content types for this purpose. The part that I'm not clear on if I am to build it myself in that manner is that for custom content types we have data types of reference/file vs general/link for the two needs (files on the server vs urls to either local content or external website). I have a preference to not have two lists for a location, one for files and one for urls.
I think I want a structure that stores one resource as a record, and which has a short description etc, so that they resource is easily resuable.
If there is a module that handles this kind of functionality that'd be ok with me.
Comments
Still hoping for input on
Still hoping for input on this. I have more or less switched to drupal 7 for this site in the meantime, there were too many issues with drupal 8 to continue.
=-=
What's the question?
Something like: is there a
Something like: is there a way to describe a content type "Resource" which can entertain both links and file references.
A clunky way to do it is to define content type "Resource", each record of which has a taxonomy type "Resource Type", which terms "File" and "Link", and define two distinct fields in "Resource", one of field type File and one of field type link. That would work, but for most rows one or the other field would be blank. If it is possible to show or hide one or the other of the fields in a view, depending on Resource Type, it might work out. I just wondered if there was a better way at hand to structure a schema like this; or a module that has functionality that solves this interest.
=-=
there isn't a module for this.
Linking to a file on the server?
Is there a simple syntax for referencing/linking to a file on the server? I am sort of choosing to use only a single field which will store a link. That's easy for a local node or an external webpage. But I'll need the same field to 'link' to a file (say pdf) on the server. I'm not sure if this will work of course.
An alternate might be to create a 'File Asset' content type, and have a File field on it to reference local files, and point to that File Asset node in the link field? This might be too complicated for the eventual site managers to keep straight.
=-=
Not sure how far along the D8 version of filefield sources module is or if there is a replacement entity but it's where I'd dig.
Could also dig into generating an entity with https://www.drupal.org/project/eck
Could also dig into https://www.drupal.org/project/inline_entity_form
Thanks for that input. I
Thanks for that input. I haven't even figured out what entities are yet. I think I have been making it too complex, and burdensome for the end users. I think I'll simply add a link field to the main content type which allows unlimited entries, and they can enter a description for the url or file.
This works ok; the only issue is that they have to know the url to a file if referenced in the link. I can get it to work using a url like
sites/default/files/private/myuseful.pdf
but they'll have to know the path and file name. Is there a 'browse to file' module that returns the relative path? I'll look just after I post this.
Your scenario just above isn't going to work
Your scenario just above isn't going to work.
Your scenario above is also a huge security risk.
You should learn as much as possible about Drupal and public file uploading in general, before creating a site that allows public file uploading and downloading.
In addition to the technical concerns, any website that allows public file uploading and downloading has to carefully prepare for all the legal complexities of doing so as well.
Also, the smart drupaler doesn't use the default sites/default/files/* directory for storing public media files.
If using a public media store just use a folder off the root of your site directory hierarchy.
It can be called anything, for example: "media", or "content", or "data", or something.
This option is set/modified at the following admin page (be careful about existing data at the original location):
admin/config/media/file-systemspritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
Yeah, it's a sure thing that
Yeah, it's a sure thing that I'm not a smart drupaler. I appreciate your detailed comments. A couple of things:
[1] You're suggesting that the default path that drupal offers for public file storage is unsafe. That is surprising. I had read before that files can be stored in a folder off of the site root, or maybe they meant root folder of my shared hosting account, but also had the impression that it's often not possible to configure that way due to hosting restrictions. I'm not sure what it adds up to. Side note my shared hosting in on Windows OS; they have it fairly locked down. Some of the normal solutions which are on linux hosting might not apply to my situation.
[2] The path I showed ended in /private and was supposed to NOT be publicly accessible. I have not been able to configure setttings.php properly so far so that the path I've created for the private folder is recognized on the admin/config/media/file-system page; not sure why. Does that still qualify as the red alert "public" file upload folder you mention?
[3] This site will have a publicly accessible front page, and all other pages will require a login. The logins are for only about 20 people who need to organize events. They're the ones that need to be able to upload and see any files in the private folder. With such a limited set of users are the security issues still relevant?
I don't have a handle on the file system stuff, hoping it becomes more clear soon.
=-=
you wouldn't put the public file system above the root. no need to if it's public.
the private folder, I'd put above the public folder to enhance security as it can't be reached at all without being logged in.
I have tested now and sure
I have tested now and sure enough, files like http://mysite.com/sites/default/files/private/Blue.jpeg are exposed to the public if you hit the url. The protection via .htaccess with denyall is probably ineffective because this is not apache, it's IIS. I found that I can create folders at the root level of my hosting environment, so that may help.
It means that in my hosted windows os environment, the layout would be like this?
-account root dir
----\mysite (has drupal etc)
----\mysitefileassets (contains files that shouldn't be public, ref'd by the drupal site)
----\someothersite (another drupal site not related to the one that uses mysitefileassets)
Is that right? If so I just need to read up on how to point the private files dir to a folder just off of the root, which is probably documented.
Reading through https://www
Reading through https://www.drupal.org/documentation/modules/file which has many many comments with many many permutations and opinions. It's really hard to make sense of it.
you can't expect to learn Drupal overnight ...
You really need to learn some Drupal basics before you try to build IBM's Darwin with it.
You can't expect to learn a huge and powerful system like Drupal overnight.
You should build a sandboxing site and actually work with Drupal's features for a while before you try to speculate about what Drupal can and possibly cannot do. In practice, with the right module support, Drupal has proven that it can accomplish quite complex website tasks.
With regard to Drupal itself, there are literally thousands of existing contrib modules that provide all manner of impressive add-on features.
When I setup even the most rudimentary Drupal site these days, I pile about 500 contrib modules into sites/all/modules, uninstalled but ready to go, so that they are there and available in case I need a feature and want to install one of them.
Also, if you actually build a public website, you may also want to consider using a web robust http server systems like nginx or apache.
We really still don't have any concrete Drupal related idea of what you are trying to accomplish.
Thus any real ability to answer your quite abstract and relatively cryptic questions is limited.
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
This is not IBMs Darwin. It's
This is not IBMs Darwin. It's a pretty simple website. I am learning a ton by building it. This is the learning curve. Some of the folks here like VM have been instrumental to helping me figure out what routes might be taken to get what I need. VM and a few others have understood my questions quite well, most of the time. A person that is new to a system doesn't know how to phrase things precisely because they...don't know the system.
I am used to building complex software systems. I'm not used to drupal, and so I have regularly scaled back what I have asked this little site to do. But I can't know what is hard in drupal, or takes level 7 knowledge of drupal, when I have only level 3 knowledge of drupal, until I hit my head on it.
You have helped me and I appreciate it. Maybe when I know how to phrase things in a completely drupal-lucid manner it won't give you such a headache reading my requests .
don't be oversensitive ...
My use of the phrase "IBM's Darwin" was just a metaphor ... not literal ... to imply that you are dreaming of building something fancy, before having developed the ability to build ... well something basic ... with Drupal's primary features, such as Custon Content Types, Views, Entities, Blocks, Panels, Display Suite displays, Taxonomies, and so on.
What I am trying to communicate is that you spend extensive time working with Drupal components before you try to make any assessment of "what Drupal can do".
Build a hundred Views, trying out various features of Views.
Attach some taxonomies to your content and see how they can be leveraged.
For example, take a look at how the Forums module employes taxonomies to implement its structure.
Check out a module like Tagscloud, to observe how they leverage the tags taxonomy to implement blocks that contains Tags clouds.
Implement some experiments with - entities - and see how they operate.
Try some experiments with the various "entity reference" oriented modules, which are extremely powerful.
Try some experiments with all the many "file" oriented modules like audiofield, link, media, and many more.
I could go on and on.
As I noted, there are literally thousands of modules, modules that implement feature beyond imagination.
Only after a few hundred hours of evaluation work will you have the insights you need to accomplish whatever it is you imagine building with Drupal.
Don't be apologetic, be busy, go setup a Drupal sandbox site, and do some Drupaling ...
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
Honestly I have no idea what
Honestly I have no idea what you're talking about. "...be busy, go setup a Drupal sandbox site, and do some Drupaling"??? What do you think I'm doing? Most of the things you suggest that I try are exactly what I'm doing. I'm learning and experimenting on a simple site. Surely the forums here are not only for drupal experts to admire each other?
I have a suggestion for you too. Other drupal experts here are perfectly capable of responding to newbie questions about the basics without asking them to "Build a hundred Views" before posting a question here. There is no need for you to comment if you have nothing to contribute. Please.
I am not apologetic. I ask questions here after doing my own research and experiments. I've gotten a ton of help from others that know their stuff. You have contributed nothing of practical use to any question I have asked about. Please don't hijack my thread with advice to the effect that I should become expert in drupal before posting here. I posted here for practical advice not a lecture.
you are asking a question that isn't handled by one module ...
You are asking a question whose answer isn't handled by a single do it all module.
Your question is presented in a way that implies you are a beginning Drupaler trying to run with Drupal before having walked a few miles in Drupal shoes.
First, your question is presented in an abstract manner. It discusses deployment of Drupal facilities without actually explaining what you want to accomplish with them, in concrete, real world, terms.
Second, your presentation of your question implies that you haven't yet gained a full understanding of Drupal's own abstractions.
Partial Drupal Concept Summary:
Content is stored in nodes.
Nodes have fields.
Fields can be entities.
Content sets are often presented using Views.
For example, using the built in article content type, a view can present a list of article teasers or full nodes, limited to and ordered based on the criteria specified in the View.
A View is placed in a region, for example the main content region or the sidebar region.
Regions can also contain blocks. For example, a site's sidebar region is usually filled with one or more blocks.
A View can be presented in a block too.
Taxonomies organize content.
Entities can be grouped together in a variety of ways, called bundles.
A field in a node can even be a reference to an entity or bundle of entities.
---
So ...
If you are going to be using your site to store files on your server for possible presentation and download, there are numerous contrib modules you'll want to know about.
For example, to store and present audio files, there is an audiofield module.
https://www.drupal.org/project/audiofield
For example there is a even a link module, that implements a field type just for including and presenting links as part of custom content types (very popular according to the usage stats).
https://www.drupal.org/project/link
Generous Drupal contributors have developed and shared many similar modules for numerous other types of entities.
- search the drupal.org modules library for others.
Separately, you should also consider using the media module, not so much for UX presentation but because the media module provides a very helpful admin/backend UI for all the "media" files stored on a site's server.
If you intend to present "files" for visitor download, consider the "download file module"
https://www.drupal.org/project/download_file
It is possible to create custom content types that include fields that are of the type of any of the just described "entities", like audio files.
--
To generate displays of content, including custom content types that include specialized entities, one uses the Views module.
The core of a View is the specification of a query into a site's contents.
The Views module is quite powerful. However, to fill any gaps in Views, others have created add-on modules that extend the functionality of Views in a variety of ways. There are literally hundreds of modules that amplify Views with additional features.
Making a View's query criteria visitor accessible is called "exposing" a "filter". For example, an exposed "filter" might enable a visitor to change sort order for a-z to z-a.
Also consider the "Display Suite" module as an addition to the Views module.
-
When designing custom content types, consider including one more taxonomy fields so that content can be organized based on those taxonomies. This is important because you'll later want to base one aspect of Views query design on those taxonomies.
-
Once you've created inventive Views, that present subsets of your content, you'll need to write scads of nifty CSS that puts a proper coat of paint on all the data so that it looks like something for users.
-
In summary, it isn't clear what you are actually trying to accomplish, but the foregoing is a summary of some of the tools you'll want to learn about in order to accomplish such a goal.
(a reference or two ...)
https://www.drupal.org/node/1649688
https://www.drupal.org/documentation/modules/link
https://www.drupal.org/node/973194
https://www.drupal.org/node/1366148
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
I am new to these current
I am new to these current versions of drupal, and it is amazing how far drupal has come since I spent much time with it. For versions 7-8, I do have a beginner's level handle on content types, taxonomies, views, some aspects of view filters, entity relationships. There is a ton I still don't have exposure to.
With this particular request I started out wanting to create something slightly complex, kind of in the manner I would with the database-based software systems I normally work with. The experiments were informative but #1 I couldn't achieve the result I wanted and #2 seemed to involve too many steps to be practical for the eventual site users. I then revised my approach to something much simpler; allowing users to link to files via path. This is what you've warned about as insecure. I can't tell if it is really a security risk since the user base is smaller and not public. By not public I mean yes the site will be at a publicly addressable url, but other than the front page all other assets and pages require a site login to access. I don't know yet if my idea that having most content behind the requirement for a site login IS sufficient to actually prevent access to files etc. I'd eventually test that; I don't even have the 'private' file folder aspect working properly.
Ultimately, for this specific request, I am looking for this: the ability to present a list of links to assets which are either urls or files on the site (pdf etc) in a view column.
I pretty much have that with the current simpler system I built; which uses a content type with a link field to store urls and paths to files in /private. If it is actually really insecure then that's not good of course and I may have to revise.
Drupal can do what you describe and far more as well ...
Drupal can do what you describe and far more as well ...
You need to spend a few months, possibly years, learning what Drupal can do, and doing some of it on a sandboxing site.
You should also consider learning how to configure a Drupal private media/file location for any website you build that involves public uploading and downloading of files.
You have a lot of reading to do, and you should practice for weeks with sandboxing site before you reach any conclusions.
As far as experience is concerned, you'll notice that the people responding to you have drupal.org accounts that are about 10 years old.
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...
a note about the audiofield module
I recently upgraded a site that is using the audiofield module to present and stream mp3 files.
Part of the upgrade was a switch to use the Soundmanager2 player.
The Soundmanager2 player is configurable and themable entirely with CSS.
The Soundmanager2 player looks like the Drupal website mp3 player of choice at the moment.
spritefully yours
Technical assistance provided to the Drupal community on my own time ...
Thank yous appreciated ...