JVG
JVG

Reputation: 21150

Drupal theming $page['content']

I'm new to Drupal and I've not been able to find an answer to this anywhere on the internet, or even the broad category of what I should be learning to understand how this works.

In my page template file, I see something like this:

  <section id="content" class="span<?php print $content_cols ?>">
    <?php print render($page['content']) ?>
  </section>

What gets printed out is something like this monstrosity:

<section id="content" class="span9">
<div class="region region-content">
  <div id="block-system-main" class="block block-system">
    <div class="content">
      <div id="node-46" class="node node-article node-promoted clearfix" about="/node/46" typeof="sioc:Item foaf:Document">
        <div class="submitted">
          <span property="dc:date dc:created" content="2013-04-03T04:17:33+11:00" datatype="xsd:dateTime" rel="sioc:has_creator">Submitted by <a href="/user/1" title="View user profile." class="username" xml:lang="" about="/user/1" typeof="sioc:UserAccount" property="foaf:name">jimjo</a> on Wed, 04/03/2013 - 04:17</span>
        </div>
        <div class="content">
          <div class="field field-name-field-image field-type-image field-label-hidden">
            <div class="field-items">
              <div class="field-item even" rel="og:image rdfs:seeAlso" resource="http://localhost:8888/sites/default/files/styles/large/public/field/image/imagefield_q6bw6x.png?itok=RfIKEaZX">
                <img typeof="foaf:Image" src="http://localhost:8888/sites/default/files/styles/large/public/field/image/imagefield_q6bw6x.png?itok=RfIKEaZX" width="422" height="197" alt="Enim incassum letalis mauris neo praesent quia rusticus venio vero." title="Brevitas esse qui ratis volutpat ymo.">
              </div>
            </div>
          </div>
          <div class="field field-name-body field-type-text-with-summary field-label-hidden">
            <div class="field-items">
              <div class="field-item even" property="content:encoded">
                <p>
                  ARTICLE CONTENT GOES HERE
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
</section>

I want to edit the way that $page['content'] renders, so I can have more control over class names (and maybe weed out some unnecessary divs). However, I can't figure out a way to control this output.

What's the best way to do this? With a custom template file? Is there somewhere I can see the markup the Drupal is using to create $page['content'] so that I can use that as a guide and make some changes to it?

Upvotes: 1

Views: 2686

Answers (1)

claire_
claire_

Reputation: 733

It seems that you're looking for the node.tpl.php template.

The original node.tpl.php is located in /modules/node/node.tpl.php although you're surely seeing one provided by the default theme you've set.

The best way to override it is to create a node.tpl.php into your custom theme.

If you want to understand more the principles of templates overriding, you could use the Theme developer module.

Here is also a link to the drupal.org documentation.

Upvotes: 1

Related Questions