Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using the core Profile module, you could use something like below. It will show the nodes created by the user whose profile is being viewed. As an added benefit, it only needs to execute one custom database query.</p> <p>Insert this snippet into <code>template.php</code> in your theme's folder and change "THEMENAME" to the name of your theme:</p> <pre><code>function THEMENAME_preprocess_user_profile(&amp;$variables) { // Information about user profile being viewed $account = $variables['account']; // Get info on all content types $content_types = node_get_types('names'); // Get node counts for all content types for current user $stats = array(); $node_counts = db_query('SELECT type, COUNT(type) AS num FROM {node} WHERE status = 1 AND uid = %d GROUP BY type', $account-&gt;uid); while ($row = db_fetch_array($node_counts)) { $stats[] = array( 'name' =&gt; $content_types[$row['type']], 'type' =&gt; $row['type'], 'num' =&gt; $row['num'], ); } $variables['node_stats'] = $stats; } </code></pre> <p>Now, in <code>user-profile.tpl.php</code> can add something similar to: </p> <pre><code>// If user has created content, display stats &lt;?php if (count($node_stats) &gt; 0): ?&gt; // For each content type, display a DIV with name and number of nodes &lt;?php foreach ($node_stats as $value): ?&gt; &lt;div&gt;&lt;?php print $value['name']; ?&gt; (&lt;?php print $value['num']; ?&gt;)&lt;/div&gt; &lt;?php endforeach; ?&gt; // Message to show for user that hasn't created any content &lt;?php else: ?&gt; &lt;?php print $account-&gt;name; ?&gt; has not created any content. &lt;?php endif; ?&gt; </code></pre> <p>This is just a general idea of what you can do. You can also add restrictions to the content types you look for/display, check permissions for users to see these stats, use CSS to change the look of the stats, etc.</p> <p>If you are using <a href="http://drupal.org/project/content_profile" rel="nofollow">Content Profile</a>, you could use <code>THEMENAME_preprocess_node()</code> and check that the node is a profile node before executing this code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload