Activating views module

Im reasonably familiar with DB stuff but a drupal novice.
I want to construct my own DB query (( for printing) .
eg all animals in a group + name+ tagID + parentage
I assume its a view
So ive been to people->permission and allowed authenticated user to ‘administer views’

but going back to ‘modules’, views_UI is on the default i assume) but I cant slide to activate the other modules .

And i’ll need phpmyadmin designer view and a VERY big screen to sort out the table relationships !

1 Like

Hi @grolma - great question…

I assume you are running farmOS 1.7 (bear with me because my head has been in farmOS 2.x for a while now, so I’m getting a bit rusty on 1.x)? Are you trying to build a UI in farmOS to give you the information you want? Or are you hoping to run a raw query?

Building a UI page in farmOS using the Views module may be possible. Views UI is essentially an SQL query builder, so it is very powerful (without writing any code or queries), but it depends on PHP plugins to describe various tables and relationships to Views so that it can offer query-building options in the UI. It is therefore very convenient in some ways, but also limiting in other ways. Maybe you will be able to build what you want with the existing plugins, or you may find that it is missing some key pieces that make it more difficult. Hard to say without diving in and experimenting (and fully understanding what you want to achieve).

I might recommend cloning the farm_group_members View that comes with farmOS, and then modifying for your needs. This View creates a page at /farm/asset/%/members, where % is the ID of the group asset, which gets passed into the View as a “contextual filter”. Combined with the group membership “relationship” plugin, this will filter down assets to those in a specific group. Then you can experiment with adding the other fields you want.

One thing to be aware of is that an animal can be in multiple groups, can have multiple ID tags, and can have multiple parents. So you’ll need to make sure your query handles those many-to-many relationships to avoid seeing duplicates.

So ive been to people->permission and allowed authenticated user to ‘administer views’

I would recommend undoing this. This means that anyone with a login to your farmOS has the ability to make changes to (or delete) Views configuration, which is both a stability risk (things can be broken) and a security risk (they may be able to access things they shouldn’t). Maybe this isn’t a concern if you are self-hosting and you are the only one using it, but I will caution you anyway. :slight_smile:

Worth noting: if you are the “admin” user (user ID 1) then you automatically have ALL permissions - so there is no need to grant additional permissions for yourself or others.

but going back to ‘modules’, views_UI is on the default i assume) but I cant slide to activate the other modules .

Hmm not sure I understand. You have the Views UI module turned on? But you’re unable to turn on other modules?

Hope all of the above helps you to get started!

PS: the “Views” module is not specific to farmOS - it is a component of the underlying Drupal framework - and there are TONS of resources on the internet to learn the ins and outs. Searching for “drupal views tutorials” is a good place to get started.