Creating different site areas that are visible to anonymous users - drupal

I am building a site that targets several audiences, or groups if you will. Nodes can be associated with one or more of these groups. It is important that when one of these groups is accessed from the main nav, the context persists until another group is selected. The group will need to be exposed to panels so that I can pass the value to various included views. Each group also has certain styling associated.
What I have attempted so far is to use Organic Groups and Context modules. When you visit one of the group nodes, there is a context rule for each group which sets a class on the body. I can probably determine the group context in panels as well (haven't quite figured that out yet). This works mostly: I can access the same node from different group nodes and the body class changes accordingly.
The problem is this only works for authenticated users, which is useless to me as all visitors to the site will be anonymous. I feel like I am probably over complicating this and welcome any suggestions!
In essence, what I need it to be able to set an 'environment' globally using links in the main nav, which I can then access in panels and pass to the included views in order to filter content.

I ended up solving this by approaching the problem in a different way. I am now simply setting a session variable whenever the user hits one of the group term pages and then using it as a contextual filter in views. This creates a few more issues in my case but nothing that I don't know how to solve.

Related

Google Tag Manager - Handling Multiple Regions Within One Domain

A similar question to this has been asked already but didn't address my query.
My company are expanding into multiple territories. These will be located within the one domain (we'll say domain.com), but the other territories will be in multiple subdirectories, such as:
domain.com/uk
domain.com/in
domain.com/us
domain.com/ie
We will be using Google Tag Manager to track the performance of our multiple campaigns, landing pages, and website as a whole.
How would we handle the adding of the container to the site, so that we'll be able to track the performance across different regions?
Would we require one container for the whole of domain.com, or would we need separate containers for domain.com/ie, ../uk, etc.?
I think you might want to create a separate view for each market in Google Analytics
You don't need a separate GTM container
Keep the default unfiltered view
For each region, create the filter specific to your filter
Example from Google
That mostly depends if you are expecting to have a similar GTM setup for all your directories; in that case it would be easiest to use the same container for all. If you have broadly similar tags you can just switch tracking ids where necessary via lookup table variables that match tracking ids to directories.
If your county setups in GTM wildly differ it would probably be more maintainable to have different containers instead of writing lots of specific triggers and trigger exceptions.
So this is not so much a technical decision (both a single or multiple containers will work), and more a question of what tags you want to deploy per territory and how you want to organize your work. But most of the time a single container should be fine.
If you are a 360 Suite customer you could have a global container with all tags common to all directories, and set up "zones" with the stuff specific to a territory that are loaded depending on the directory.

Is it possible for two or more Drupal Views Page displays to share the same path?

I would like to have a user land on a page and see on view that depends on her role. When I tried to create two views with the same path, Views did not object. But I'm wondering if it's not meant to work this way.
Is it two views or two displays on the same view? According to the maintainer of the Views module, two displays on the same view are meant to be able to have the same path, but two different views should not be able to have the same path.
If the results of the view are based on the user's role then I would recommend using one view/display but use the user's role(s) as an argument.
If you have a small number of roles that don't change very often you could create individual displays and adjust the display's 'Access' settings in the view for each one. I would not consider this a best practice but there might be certain situations where this is fits the bill.

Filter a view by user-created tags in Drupal?

I'd like to add a block to the user profile that shows them content listings in their groups based on tags that they have in their profile.
(ie: someone puts a bike up for sale, the user has listed "bike" on their wishlist, it should show up to get their attention)
Since these tags vary user-to-user, I'm not sure exactly how to set up the filter.
Going a little farther, can I sort them by the number of matching tags?
I've found that taxonomy terms and views can be very tricky to get right. The main problems is that taxonomy terms has a one to many relationship with nodes, and views is built to be generic.
It might be quicker to create such a block in a custom module instead, because you may very well get stuck in views before getting what you want. Also you most likely have to create your own sort plugin for views, to get the sorting you want. I haven't seen any module creating something like that, and I don't think it's possible with views core. Creating plugin for views can be very harry, the first time you do it, so unless you know your way around views, I think you will have more luck just creating a block yourself. It's much simpler, than having to extend the views functionality.
Have you looked into Views? You can set up a block with views that retrieves (almost) ANY information from the database.
In your case, you can filter the information that you need and that belongs to the current user, also, sorting is doable via the Views administration.

Context module for block visibility

I have a site built in Drupal 6 that requires a number of blocks that are only visible to certain roles or on specific pages. Normally, I would use the block configuration settings to control page and role visibility. However I recently ran across the context module that effectively splits the site into "sections" or "groups" of related attributes.
My question is: When is it appropriate to control block visibility from context rather than the block configuration settings? Should I only use one or the other or a combination of both?
these are different approaches meant for different use cases, but they are not mutually exclusive.
context indeed splits the site into different contexts (and there is also the possibility of context types). and that is effectively its use case: context-based block showing/positioning.
however context won't check for user roles nor multilingual settings (i18n). block supports these cases (and you can combine both context and block to show something on a context depending on user role).
block also allows users to choose whether they want to see the box or not.
my final answer is: combine instead of choosing.
There is no hard and fast rule for when to use core block placement, and when to use context. In general though, if you have a lot of blocks, with different and complex visibiity logic, context will make things more manageable. Additionally, contexts can be exported to code, which allows one to more easily track block configurations in version control. When storing contexts in code, this also allows changes to blocks to be deployed to a production site by simply updating the code, rather than needing to log in and manually move things around via the UI.

How to show inactive task tabs in Drupal

Is there any way to show local tasks to user if they doesn't have necessary permissions? Right now it seems like Drupal just excludes them from page code. I want to show them, but with different CSS class.
Version of Drupal is 5.20
Even though there are some differences concerning the local task building between Drupal 5 and 6, Mac is right that the logic to ignore entries not accessible by the current user is pretty deeply embedded in the menu.inc functions. If you want to look for yourself, start with theme_menu_local_tasks() and follow the function calls from there.
If I had to implement the feature you're looking for, I'd rather avoid Macs suggestion of messing around with the menu access settings directly. Instead, I'd override theme_menu_local_tasks() with a custom version and duplicate the entry retrieval logic in there. The first run would fetch the primary and secondary links as before, and the second would do the same while impersonating another user (probably user 1 in this case). That way, I'd get two versions of the local task markup which I'd then needed to diff somehow in order to find the ones not allowed for the current user, thus needing the extra CSS class.
Note that this would still be somewhat ugly to do, as menu_primary_local_tasks() and menu_secondary_local_tasks() return already themed lists, so the comparison would need to work on the markup, probably parsing out the li tags somehow. So it might be worth spending some time trying to do the same thing (fetching the local tasks as two different users), but using lower level functions to get the entries before theming.
Note: Should you end up using the user impersonation logic, make sure to use the safe, second version that disables session saving during impersonation.
I know the D6 version of hook_menu much better than D5's. AFAIK - however - you can't override that behaviour as it is hardcoded in menu.inc.
If I am right with what above, a workaround (rather inelegant, I must admit) could be:
Remove the access control from the menu item, so that all menu items are visible to all user.
Put access control in the callback directly (you will make the tab non-clickable in a moment, but if the user insert the URL directly, this will prevent access to pages they must not see).
In the page displaying the tabs, load a different js file according to what roles the user has. The js file for users with limited access will select tabs by mean of their text content (at least in D6 tabs do not get any "individual" class: they only get a common "tab" one), it will remove the link to the tabs the user has no permission to visit and it will add a custom class to those tabs that should be displayed differently.
Add CSS theming for your custom class.
As stated before, I do not know D5 much, so it might also turn out that you can actually achieve what you want in a much cleaner way!

Resources