Reputation: 1466
I am a beginner in drupal. I am developing a site for students and educational institutes where the institutes need to display their information in a single page. A content editor will add an institutes info (name , description, courses, facilities, contact info etc) and I want to have a tree structure for listing institute by category and names.(It will be in left sidebar)
The institute info need to get displayed in different blocks (like contact info on top right Name and description in main content , courses in right ). I am not very well versed with views. I know how to create regions and place content in there. I can make template using html and css. How should I go about implementing this. Thanks in advance.
Upvotes: 0
Views: 2192
Reputation: 375
First, you should set up a Content Type 'Institute', with all necessary fields you want to display ( main text, contact info, etc .. ). Then make a seperate Content Type 'Course', and create the necessary fields as well.
To hook up the Courses with the Institutes, you should make sure there's a Node Reference in the CT Institute. That way, you can - during Institute creation - link Courses. The field has several settings, including autocomplete, select list, etc .. I assume it should also be set up as 'multiple', because I doubt that an Institute will have only 1 Course.
Configure your CT Institue, Display fields, so that it only shows whatever's needed in the main content window. The other fields you just mark hidden.
Then create a view, using the Block display. Give it an argument of Node:Nid. And pick the setting 'Provide default argument' => Node ID from url. That way, when you are viewing Institue A ( which has for example Node ID = 1 ), the Node ID of Institute A will be passed on automatically in the View. Further configure the View : limit it by Node Type Institute, and add the View Fields that you chose as hidden in the Node Display fields. So if you chose to hide 'Address', add it as a field to your view.
If you then configure your Institute nodes to always have the path 'institue/[title]' ( the module Pathauto can do that for you ) , you can configure your Block to only display on the paths 'institute/*', and for example in the left sidebar.
If all went well, when you now go to Institue A, you should only see the fields you chose in the main window, with all other fields being display in a block on the left or right sidebar.
To setup a view with Courses for that specific Institute, you also have to add an argument Node:Nid from the URL, but you have to add a relationship as well. This is because you don't want to display Institute fields in that block, but rather Course fields. If this is setup correctly, don't forget to add the fields, and indicate that they should use the relationship.
I hope this will help you on your way!
Upvotes: 1