I am new to Drupal, please go easy on me if I am asking something stupid here.

I have installed D7 and it works fine. I have started creating a new theme using Stark as the base theme. I have been able to add some custom content fields for basic pages by using the Manage fields option under Manage content types. So far so good!

What I can't seem to be able to do is now target the content which is filled in when you create a node by CSS. The ideal solution for me would be to wrap the content in a unique class for each piece of content but I am unable to find anything online to tell me how to do this.

Any advice or links to tutorials would be highly appreciated.

Comments

devtherock’s picture

firebug when you are on node landing page you will find, unique css id for different nodes

dhroople’s picture

Add this code to your content div. It will have a unique id for ever node.
<div id="node-<?php print $node->nid; ?>" >

wgd’s picture

I can't seem to locate the node.tpl.php file in my new theme. I duplicated Stark as the starting point for my new theme and it appears that it does not have this file? Is that right or am I looking in the wrong folder?

devtherock’s picture

Copy it from garland theme and then paste in your theme, do changes you want, rebuild theme. it will reflect changes on node page.

wgd’s picture

Forgive my ignorance here, PHP is not my forté. I have copied Garlands node.tpl.php file and have the following code

<?php
// $Id: node.tpl.php,v 1.24 2010/12/01 00:18:15 webchick Exp $
?>
<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?>"<?php print $attributes; ?>>

  <?php print $user_picture; ?>

  <?php print render($title_prefix); ?>
  <?php if (!$page): ?>
    <h2<?php print $title_attributes; ?>><a href="<?php print $node_url; ?>"><?php print $title; ?></a></h2>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <?php if ($display_submitted): ?>
    <span class="submitted"><?php print $submitted ?></span>
  <?php endif; ?>

  <div class="content clearfix"<?php print $content_attributes; ?>>
    <?php
      // We hide the comments and links now so that we can render them later.
      hide($content['comments']);
      hide($content['links']);
      print render($content);
    ?>
  </div>

  <div class="clearfix">
    <?php if (!empty($content['links'])): ?>
      <div class="links"><?php print render($content['links']); ?></div>
    <?php endif; ?>

    <?php print render($content['comments']); ?>
  </div>

</div>

I need to add the code dhroople suggested

Add this code to your content div. It will have a unique id for ever node.
<div id="node-<?php print $node->nid; ?>" >

Would I do this by wrapping all the php in this file in another div with a class of content and then the PHP dhroople has suggested? or do I add it as a seperate block of code?

devtherock’s picture

Actually you don't need to do anything, if you go content page ( in Drupal term node detail page) and firebug content you will see a unique id for your content. This will be different for each content.
however you want same thing in class you can do as follow


<div id="node-<?php print $node->nid; ?>" class="<?php print $classes; ?> node-<?php print $node->nid; ?>"<?php print $attributes; ?>>

I am wonder why do you need different id/class for content.

wgd’s picture

I see it now, there is already a unique id for the content like you said. This is just what I need to target certain content with its own speciofic style.