Drupal - Modify tabs added to user page by Views - drupal

I've added a number of new tabs to the user page, using Views (as a page with menu tab settings etc.). What I now want to do is remove them if the viewed user is the current, logged in user.
Prior to adding some user filtering, my first problem is that I just can't seem to modify these tabs at all. I know the general procedure is to use HOOK_MENU_ALTER and (for example):
$items['user/%user/view']['type'] = MENU_CALLBACK;
This works fine for the original tabs, but not for tabs added with Views, e.g. for an 'Articles' tab:
$items['user/%user/articles']['type'] = MENU_CALLBACK;
Are tabs added by Views handled differently to 'normal' tabs?
Cheers,
James

First of all you won't be able to hide them dynamically by making them MENU_CALLBACK. What you should do is change the access callback to a function where you would check for the current user.
As for why you can't find the tabs, check if:
There isn't a menu entry with
%views_arg instead of %user
That your module's weight (in the system table) is bigger than views' weight. Since views uses the same hook it's possible that your module gets called before views.

I think views is adding all it's stuff in hook_menu_alter(). To change it, you need to give your module a higher weight in the {system} table than views has.

Related

Auto-associate page metadata?

Links require SDL Live Content login.
We can choose default schema (and a mandatory option) in folder properties. New components in these folders will have the schema selected with appropriate fields filled out.
We can choose default page template for structure group (SG) properties. New pages in these SG will have the page template selected.
Do we have a similar option for page metadata such that in a given SG, author gets both page template and predetermined page metadata (fields) for either:
page creation
page template selection
We can do this easily with Inline Editing (SiteEdit) and page prototypes. But how would you configure or implement this type of requirement with the Content Manager Explorer?
I'd say there are a number of ways to achieve this:
1) Using the UI 'Page Types' - If the page you are using as the page type this should keep that same metadata. *I've not tested this!!! maybe you could confirm?
2) GUI extension - When a page template is selected a page metadata is selected based on the page template.
3) Event system. I'm not sure how well this would work as it would likely have to be on the creation of the page (checking if a default template is used) or on save if a template is used and a metadata schema isn't selected... but then if there is mandatory metadata etc etc.
4) The page template. This will set the metadata (on publish or preview) - or warn a user that a specific metadata should be set for this given page template.
Hope this helps.
Thanks
John
Very interesting question and I can see the benefits of this functionality for Editors. I don't have the answer for you. But AFAIK, even event system might not be relevant here since there are no events fired when you start creating a page unless we save the page. GUI Extension a possibility?
When you create a new item, this takes place via the GetNewitem() method in the API (or GetNewObject() in old money). I always thought there should have been separate events system hooks for this activity than for that of modifying an existing item. I once suggested this on ideas.sdltridion.com with regard to Components, however someone referred me to the OnSchemaGetInstanceDataPost event hook, and the discussion was over.
So in the case of a new component, the schema is automatically queried, and via the hook, you can interfere with the default data. So far so good, but I still believe that it would be generically useful to be able to modify the default data of any item type when first created.

How to provide a button which will change my current page content to an previous page in drupal

I'm making a site wherein I want to show the current course that I'm gonna teach to my pupils.In this page there should also be links provided to my previous courses. Now when I'm done with this course I want to transfer it to a previous course or rather automatically create a link for it and get the new course content in it's place. I just think doing manually is kind of stupid. Rather I want to have a form where i can create my new course then click on make current course as previous and this course as new whenever i wish.How can I do this.Is this even possible
Pretty open question ... One way would be to work with views when showing a node.
In the view you should use a custom php field, which collects the record (nid) within the course-node table. And then create a link using the drupal path_alias function or by using node/nid ...
You could use panels-module as well. Where you have a view with the latest course, and under the latest course you have a view of a link to the latest course -1 . (I think you can set an offset in views to get the previous course) The view should accept an argument, namely the nid of the currently loaded node.
If you use this method, do check if your panels is giving the arguments to the views module.
Another way would be to use node reference as to what is the previous course (but you don't want it to be manual). The advantage of node_reference is that you don't need to enter your courses in a certain order. If you make it automatically, then the order in which you fill in the courses should be correct.
Easy man. Just create a content type called "course" and using CCK, add all the fields to capture information you want about the course.
Now you have the content. Using Views, create a simple view page displaying course content type and sort it on descending order, set it to display one item at a time and add a mini pager. That way the new course will be the first one displayed and the other ones will be behind it. You might need to customize the pager a bit ^^

Drupal views & to do list

Wondered if anyone can tell me whether the following is possible within views.
I have installed To do module - http://drupal.org/project/to_do
I then created my own view which lists all the tasks created in a particular Organic Group, which works lovely.
One of the fields ive added as the to do button field which gives the user the ability to mark a task as finshed from the view listing.
the problem I have is that all users part of that group can see that buton & has the ability to mark the task as finished.
Is there a way I can use views to only show that button if the current logged in user is the author of that node( to do task).
Views have different templates. In one of them all the fields are being printed. You could in that template make a check if the user is the author and then only print the todo field.
You cam click the theme information link inside the view to get a list of templates that's used and what you could call a custom template for views to use it.
This will only show content the user created. It's a pretty simple argument

Drupal Custom Form with Filters

I'm displaying cars on a page created with a view and displays. I want to be able to create a form on the home page to allow people to select the 'make', which will then update the 'models' list based on the 'make' the user selects, 'year' to and from, and 'amount' to and from. What the user selects will of course alter the list of used cars, whether that's on the existing used cars page or a new page.
I would be happy to create a custom module if required, just need some direction.
Thanks !
When using views, what you need to do is to use exposed filtes. Inside your view you can setup filters like normally, only when you expose them, the user get to change the value of the filter.
How the filters will be themed to the user will depend on how you store the values, so it's a bit hard to say how to progress from there. It might be a bit tricky to get a select and not a textfield. Once you get select fields, this could probably be done with either some theming or form_alter, all you need is to add some js to change the options. The js part should be pretty normal, you will probably need to fetch the model names and values using ajax.

Drupal, Views, Exposed filter: custom default selected tags

I'm using Drupal, Views with a exposed filter (using taxonomy).
My customer wants to set from back-end the default selected tags (in order to pre-filter the views content).
In the exposed filter settings, there is functionality. However, it doesn't work properly: when I click on "Select None" link (I'm using better_exposed_filter module) I expect none of the tags are selected, instead, the default configuration (default selected tags) are selected, so actually it doesn't work anymore. I hope it is clear.
So, I was wondering if I can prepare a custom menu in which my user can check/uncheck the default selected tags in the view.
thanks
You could achieve this with hook_forms_alter to change the default selected entries, but if the exposed filter isn't using your selected ones by default then there may be a bug that's worth filing on the module.
I've created a new homepage with a CCK forward link.
My customer can select the tags in the View, and copy paste the URL after the changes.
The homepage automatically forward to the personalized view URL.

Resources