Hi! I'm new to Drupal. I just started last week.

I'm building a website which has sections full of articles. (We have about 20,000 so far on our old site.) What I'd like to do is add certain articles so they show on certain pages. So, for example, I might click on Recipes > Pastries, and it will show all articles I've placed under that category which relate to pastries.

How do I do this? I'm guessing I can either add an article to a page, or I can create categories, mark articles as being under these categories, and displaying the categories on specific pages.

Either way, I'm new to Drupal and don't know how to do this. Could someone please point me in the right direction?

Thanks,
Brendan

Comments

stefan lehmann’s picture

I think the keyword you're looking for is taxonomies: https://www.drupal.org/docs/7/organizing-content-with-taxonomies/organiz...

If you have learnt how to use them and you find you're hitting a wall on how to display things you might want to make yourself familiar with Views.

bdparker’s picture

Ay, heck. Just when I thought Drupal was making sense, here's another paradigm I have to learn. That's ok. :) It's working out great so far! Thanks for your help!

stefan lehmann’s picture

Both are very elementar Drupal concepts and sooner or later you'll have to learn about them anyway, as they are pretty much standard components of any professionally built Drupal website. :)

vm’s picture

views.module generates lists of content via criteria you set.

bdparker’s picture

Ok, I create a view and can list my articles based on criteria. I have that working really well now. But let's take it a step further. I want to put, at the bottom of my article page, six boxes of links which each have their own criteria for what they display. Is there a way I can place the output of certain views on my page by using php code?

Like, maybe I can make a

tag and say something like this:
<div class="myBox">
<?php print(views['name_of_my_view'];)
</div>

I don't expect that code to work, but is something like this possible? Is this the best (or at least an appropriate) approach for it?

Thanks,
Brendan

stefan lehmann’s picture

Yes, there are ways to print out a view like that. But normally it always pays out to write as little custom code as possible.

If you have a look at your view, find out how to add a new display. If you add a new display of the type Block you can add this block to any region in your theme. That'd would be the much preferred way.

Check out the block management under Structure > Blocks

bdparker’s picture

Hmm... this seems like the right direction. I'm not quite sure what to click or where to look. I'm in view, but I don't see the ability to add a new display? (Sorry, I'm still new.) Is there a video tutorial somewhere? I can't seem to find the right thing, but then again, I'm new and I might not quite know what I'm looking for.

BUT there's a chance I might actually have understood what you were saying. I access blocks and I can choose which regions they appear. I can also set conditionals to show only on certain content types (or whatever). That's cool! Is that what you're saying?

If so, that gets me really close to what I want to do. In fact, it might be exactly what I want to do, but I'd definitely like to have more control over how they appear.

I'd still like to know if I can call a block through PHP and have it appear in the template, since there are some nonstandard things I plan to do which aren't in the template. I'd also like to sometimes make the block appear within the content.

Thanks!
Brndan

stefan lehmann’s picture

I'd still like to know if I can call a block through PHP and have it appear in the template, since there are some nonstandard things I plan to do which aren't in the template. I'd also like to sometimes make the block appear within the content.

Every line of code you write adds to your technical debt. Trust me, if there is a way, that you can achieve it via the backend UI in some way it will pay out a lot in the long run.

If you still really want to hand code a block, have a look at the example modules. There are code examples for almost every standard use case.

There should be lots of Views tutorials around. Here is just a random one I found when I searched for Views & Blocks: https://www.youtube.com/watch?v=BebR07kucT4