I wasn't sure where to put this topic but, I am trying to do a table view of some properties(houses) and i am using the publish content module to allow the client to publish and unpublish properties. I was wondering if it would be possible to apply a div class to property by if its published or unpublished.

Comments

merlinofchaos’s picture

Status: Active » Fixed

Add the published field. Set it to exclude.

Create a theme template (see theme: information and the advanced help on themeing for details) and override the table theme. When displaying the rows, you can look into the result data and apply a class to the row using that data.

chrislabeard’s picture

Status: Needs work » Fixed

Would it be possible to add a php statement saying

<div class="<?php if ( $published = yes ) {
	echo "published";
} else {
	echo "unpublished";
}
<?php endif; ?>">

chrislabeard’s picture

Status: Fixed » Needs work

Would it be possible to add a php statement saying

 if ( $published = yes ) {
	echo "published";
} else {
	echo "unpublished";
}
<?php endif; 

">

chrislabeard’s picture

Would it be possible to add a php statement saying

 if ( $published = yes ) {
	echo "published";
} else {
	echo "unpublished";
}
<?php endif; 

">

dawehner’s picture

What do you want to say with this?

You can theme the content, yes. Therefore you have to add the published field, as hidden, and check the variable.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

millenniumtree’s picture

Here's a template I created.
I have a view named 'search', that essentially overrides the site search.
I wanted to display some of the results (products), side-by-side, and the rest of the results on top of each other (clear:both)
I couldn't tell the different content types apart in the view, so I modified this template to add the content type into the views row.

Note the filename views-view-unformatted--search.tpl.php - it only overrides the search view with the unformatted style.

<?php
// $Id: views-view-unformatted--search.tpl.php,v 1.6 2008/10/01 20:52:11 merlinofchaos Exp $
/**
 * @file views-view-unformatted.tpl.php
 * Default simple view template to display a list of rows.
 *
 * @ingroup views_templates
 */
?>
<?php if (!empty($title)): ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>
<?php foreach ($rows as $id => $row): ?>
  <div class="<?php print $classes[$id]; print ' views-row-type-'.$view->result[$id]->node_type; ?>">
    <?php print $row; ?>
  </div>
<?php endforeach; ?>

As you can see, this bit...

print ' views-row-type-'.$view->result[$id]->node_type;

...is what adds the content type. Quite a lot of information is available in the $view->result[$id] object.

And don't forget to clear your cache on the /admin/settings/performance page.

I hope this helps someone.