Drupal Custom Form with Filters - drupal

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.

Related

Two Blocks for sort filter Views — Drupal 7

I have a view in Drupal 7 with results including a field of date and another with price, I need to sort the results by means of these two fields when I click on the appropriate link (not button or dropbox radio), but the trick is I need add the different sort filter into two separate blocks, because each block will have a different per user context.
Besides the filters should be links. Any idea how to work this?
You can have different displays for all order variations and then use appropriate one depending on parameter passed with link. Of course, you can't just use block view, but create your custom block which will embed correct view depending on that parameter.
Other way would be altering view query. In you module add hook function for altering view and inside you should detect your view, check for parameter and alter order value.
You can create two block displays for the same view, each of them sorting the results with a different criteria. Once both blocks are created, enable them in the same theme region and establish the URLs in which each module should be displayed. This configuration can be set using the block configuration form.

Client management page on Drupal 7

I would like to know what is the best way to create a custom page for my client where he can update is content by himself, the simpliest way possible for him, without even entering drupal management.
I would like to create a page with different dropdown list where he can't update a table on a page, only by selecting an item in those and add other dropdown list as well.
For example: he logs in a custom page
Theres a list with different kind of fruits, he choose banana and it automaticaly update a page table and update it with banana.
After that he could also create a new drop down list of vegetables for example, and add different kind in it so he can use it to update the site later. All that done with ajax as well.
I'm very new to drupal and have a couple of php notions, but i don't know where to start, would it be in CCK, Views or Form Api or the three at the same time?
Or is there a module out there doing that kind of thing?
English is not my primary language, so sorry if it isn't very clear.
Thank you very much.
I think what you are looking for is CCK module. You can create a CCK content type and have a field within it called fruits. From the admin interface you can decide what are the values that should be in the dropdown.
You can give the client permission to create a node of the content type. If you think he should be able to edit only the drop down values, make sure you give him the permission to only that field.
You can create a listing page using http://drupal.org/project/views or you can also consider using
http://drupal.org/project/editview
You should take a look at views bulk operations, and try using the "modify node fields" feature which will allow you to perform bulk operations on node fields displayed in a view and then look into roles & permissions which will help you restrict viewing the "View" by role.

How to create a custom form in drupal

I need help on how to create a 'custom form' using the same fields provided by cck.
Drupal gives you the ability to add fields to 'nodes' and how to theme their output. But I would like to be able to post a data from my own form (that pops-up) and sends data to the drupal database using the same drupal cck.
How do I access the specific form inputs to add data to my content types ? because the default form is kind of 'ugly' and loads on different page(without ajax).
Help would be much appreciated
There are several routes you could go down.
The easier option is to use the Webforms module. While this gives you similar fields to cck, they are not exactly the same, and if you have a module that implements a specific cck field type, it won't be available to webforms.
The second choice is to write your own module using the forms api. This can mean a lot of learning, add it takes time to get up to speed, but ultimately you have total control over how your form will look and behave. The forms api doesn't give you exactly the same fields, but all the tools are there to create them. Sometimes you need to hack open a module to find out haw a specific field is implemented.
A third option would be to use cck itself. You could create a content type and add the field types you want on your form. You would them give users permission to create but not view or edit the content type. The form submissions would them be nodes on your website. This would make me slightly nervous, so make sure all your permissions are correct!
The second part of your question: you can use a theme file to override the appearance of most forms and make them pretty.
James

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 ^^

Search forms linking to actual search page

I have created a search page uising exposed filters and views module. The user can choose from different values in order to get a table with specific results (returning node fields). This page is located under mysite.com/search. The problem is that I would like to put a simplified version of the search form on my homepage (lets say just the keyword search box + one or two checkboxes). This can be a block or a view. When the user presses the search button I would like to redirect him to the search page and show the results. Here the user shall be able to refine his search in an ordinary way. I guess this can be achieved by HTTP GET parameters and pointing to the actual search site. I was wondering however if I could do it without hardcoding the forms on my homepage, i.e. by using views, blocks, etc. I hope this makes sense. Any help will be appreciated.
Edit
The end result is that you want to have one form bring you to the search results page, and another advanced form on the search results page itself. This solution accomplishes this by creating two identical views with different filters for each form.
When someone uses the simplified form, they're taken to example.com/search, and when they're on that page and use the advanced form, they're taken to example.com/search/advanced. Because the views are identical with similar paths, the end user won't know the difference.
Here's how to accomplish this:
Create a view for the search results. Use the default display to set up the search results however you want. For filters, only put in automatic filters: don't put in the stuff you want the user to be able to filter by.
Create a new page display in that view. Give it a path of search. This is going to be the results page that a user hits when they use your simplified search form.
In this page display, override the filters. Set up and expose the filters you want for the simplified search form.
Override Expose form in block in the Basic settings for this display and set it to yes.
Create a new page display in the view, and give it a path of search/advanced. This is going to be the results page that a user hits when they use the advanced search form.
Override the filters for this display, set up and expose the filters you want for the advanced search form.
Override Expose form in block in the Basic settings for this display and set it to yes.
Now, you'll have two view pages, search and search/advanced, and two blocks, a simplified search form and an advanced search form.
Go to the block administration, and enable the simplified search block. Use the path specific visibility settings to set where you want the simplified search box to appear.
Now, enable the advanced search block. Use the path specific visibility settings to set the visibility to:
search
search/*
Let's say you wanted to create another simplified search block with a different set of filters (let's call this alternate). You can do that too: create another page display in your view as you did in steps 2-4 but instead of using the path search, give it a different path: search/alternate. You can add as many simplified forms with different filters as you want, and they'll all have the advanced search form and the same results when you use them.

Resources