Views: Limit amount of a node type by percentage I have a view showing nodes of two different types sorted by date.
I want to limit the maximum number of nodes shown of the one type by, say, 25% percent of the total nodes per page.

How would I go about that?
This might be a job for _views_pre_render().  In it, you can go through your views results and modify them to your module's content.  The issue here is creating a view result big enough to make your percentages work. For example, let's say you want to have that view of 4 nodes, but only 1 of which is of a certain type.  Since you are sorting by date, if the first 4 are all of that type, you grab one but need to keep looking for 3 of the other type.

In a dull ax approach, you could, though, create a view that returned 100, or however many is reasonable on your site based upon what you actually see re mix of nodes, of both types sorted by date and then do something like:

function YOURMODULE_views_pre_render(&amp;$view) {

  if ($view-&gt;name=='NAMEOFTHEVIEW') {

    //  drupal_set_message('&lt;pre&gt;' . print_r($view-&gt;result[0], true) . '&lt;/pre&gt;'); // just the first row
    //  drupal_set_message('&lt;pre&gt;' . print_r($view-&gt;result, true) . '&lt;/pre&gt;');    // all of them

    $max=1;    // hardcoded for example purposes
    $total=4;  // hardcoded for example purposes

    $new_result=array();

    foreach ($view-&gt;result as $result) {

      if ($max &amp;&amp; $result-&gt;FIELDTHATHASTHENODETYPEINIT==NODETYPEWEARELOOKINGFOR) {
        $new_result[]=$result;
        $max--; $total--;
      } elseif (--$total) {
        $new_result[]=$result;
      }

    }

    $view-&gt;result=$new_result;

  }

  // any other views_pre_render()ing here

}


which if my logic gene is in gear today will cycle through your view results and pick out at most $max nodes of one type and then fill up $new_results up to $total with the rest of the view results and then replace the results of the view with that.

The issue, again, is that if all the results are of one node type, or there aren't enough of the other node type to fill up $new_result, you will have less than $total results returned.

(One or both of the drupal_set_message()s will/might be helpful for figuring out FIELDTHATHASTHENODETYPEINIT.  If there isn't one in your view already, you can put one in and then not display/hide it if necessary.)