Hi there,

I've currently configured an image gallery the way it's descriped on this page:

http://drupal.org/node/144725

I made a couple of Views, acting as different image gallaries. Then I included an php(mysql) statement in the Views header, displaying the total count of images (using the mysql $count on "node type" image):

  $mytype = 'Image';
  $count = db_result(db_query("SELECT COUNT(DISTINCT(n.nid)) FROM {node} n WHERE n.type='%s' AND n.status=1", $mytype));
  echo "Aantal: $count";

I am wondering if it's possible to extend the mysql WHERE statement above, by including CCK fields?

For example, I am currently using a CCK called "Image" where i have added a 'category' field, so I can make different image galleries. Can I extend the WHERE clause above to include this CCK field 'category'? (the View is using this 'category' field also in the Fields section of the view itself...

Thanks!

Comments

dawehner’s picture

<?php
db_result(db_query("SELECT COUNT(DISTINCT(c.nid)) FROM {node} n, {content_type_page} c WHERE n.type='%s' AND n.status=1" and c.field_$fieldname_value = %s, $mytype, $string2));
?>

This should work
----------------------------------------
May the source be with you! :)
Jabber me: dwehner@im.calug.de German Drupal IRC Channel: #drupal.de Join!

speis’s picture

Thanks,
But I made a mistake, it's not a field i need, I am using a filter (category ''is one of" 'holiday') to display the images.

Will "c.filter_category_value = 'holiday'" work instead of c.field above?

Oghnia’s picture

subscribe