views:

103

answers:

3

I'm new to Drupal.

I have a couple of Content Types and some of them have a special field called Foo. This field has value 1 for some Contents and 2 for others.

I need to create a page that will list all the Content Types which have Contents with Foo equals 2. In this list, each item must be linked to 'some-page/$s', where $s is the Content Type.

Initially I thought about creating a module and writing raw SQL, but since I don't know te Drupal database structure yet, I decided to try a solution with Views. I ended up with almost exactly what I need, but I can't create the link right, because the Content Type is being printed with underscores in the place of hiphens.

Any help? If you know a different solution (with no Views), please post it.

Thanks.

+1  A: 

You make the url somepage/content_type but instead wants the url somepage/content-type.

The solution to this problem depends a bit on what it is you want to do and why you want to have the -. Drupal has the path module (a part of drupal core) which will allow you to change the appearance of urls. So drupal can make the first url look like the last url. Now if you have already made this url, and want to map to it, I'm not sure what exactly would happen if you make use of path alias'. It might fix the problem, but since Drupal internally knows the difference, you might not get to the page you want.

googletorp
+3  A: 

views is definitely the right path. you're probably better off with an exposed filter. you can also try the summary option in argument, that way you can see what arguments they are expecting (like somepage/blog-post). if it expects somepage/blog_post, but you need somepage/blog-post to work, try aliasing it with the core 'path' module.

barraponto
+1  A: 

AFAIK the fact that you're limited to using underscores is due to restrictions placed on the naming of content types.

As the solution you have goes a long way to solving your problem, it might be worth trying to create a path alias pointing from somepage/content_type to somepage/content-type using the pathauto module.

codeinthehole

related questions