4

I need a little advice or guidance on the structure of Drupal 7. I have used Wordpress for a number of years and I know it very well. Moving to Drupal 7 has got me a bit confused if I'm honest. Take an example of a news page which may have a description and possibly an image at the top then afterwards gives a list of news posts.

In Wordpress (including the Magic Fields plugin to create custom fields) I would create a news page type and news post type. Each would have there own template file. In the news page template file I would output the fields of page then call the Wordpress loop which would give me the list of news posts.

In Drupal 7 I understand that I would create two new content types news page and news post. I would also have two template files - page--news-page.tpl.php and page--news-post.tpl.php. What is the best practise for getting a list of the content type "news post" (list of nodes)?

I've done some reading on this and looked into views. If I create a view to do this, would I set it to a block then call that block within my "page--news-page.tpl.php". Or is there something similar to the Wordpress Loop?

I understand you can create a view as a page but then I would not be able to have fields specific to that page - like the description and image.

2 Answers 2

1

Views allows to add custom text (with a format, so it can contain html) before and after a view. This could be a possible option.

Alternatively, if you for example want multiple news pages (kind of like news categories although taxonomy might be a better option here), have a look at the EVA project, which seems to be the successor of Views attach. This allows to add a Views to a node (or another entity like a user).

To assign news items to a specific page and only display it there, you could add a node reference field to the news item node type and then pass the node id as an argument to the view (EVA supports that according to the project description). But again, using taxonomy might be a better option for a categorization like this.

0

Use Devel & Theme developer to get your template suggestions. That is as you create new content types you can create new .tpl.php files to target different aspects of it, the same is true for views if you go into the "theme information" link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.