Hi!

I am working on a new theme for my website using PHPTemplate. I've built it from the standard template.

Most things I figured out. But there is one thing I just can't find. There are offen used different variable with print. Then those variables have html code which I would like to structure and format.

Example 1:

<a href="/ <?php print $node_url ?> " title=" <?php print $title ?> ">

Example 2:

<div class="content">
   <?php print $content ?>
</div>

OK, in example 1 there is no problem, because $node_url only contains a url. Good.

But $content in example 2 contains a lot of different content, formatted with html and so on. Where do I find this? Where can I change the html for that? I just don't find it. Is there a special template for the content?

Kind regards,
Holger

Comments

tiff’s picture

I think that $content is simply whatever text you (or a user) enters in the textarea box when editing a page. There is no 'template' per se, nor is one needed, as it is by definition the part of a page that is different for each entry.

If you mean customizing the appearance (font style, size, colour, etc.), that is adjusted by editing the settings in style.css. You can edit the appropriate class for the content for your theme; for instance, the format for this comment is determined by the settings for class 'content' in the style.css file for this theme.

A really useful tool to figure out what css class a particular bit of text is is the web developer's extension toolbar in Firefox (http://chrispederick.com/work/webdeveloper/). Install this, then you can right-click, select Web Developer, Information, DIsplay ID & Class Details, and you can tell what to edit in style.css to change a particular element of a page. Much easier than trying to figure this out by looking at the Drupal back-end files.

See also the node.tpl.php handbook (http://drupal.org/node/11816) for some more information about the variables used in nodes.

I am still figuring out phptemplate, but generally speaking you change layout (where things show up on the page) in the template files page.tpl.php and/or node.tpl.php, and change the appearance of different elements in style.css. By experimenting and making yourself familiar with these files you can do quite a bit of customization.

- T.

Holgerson’s picture

I might be totally wrong (don't have my drupal installation at hand as it is at home on my test server).

But, as far as I could see from the source code, there is more in $content than simply the content entered in the text fields (which actually sounds sensible that it would only be the content). But maybe I am totally wrong on that. But where does all this code come from if not from $content??? ;-)

I will have a look into it.

And by the way: I am totally aware of the oportunities of CSS. Therefor I want to "clean" the code and be able to influence everything on the page.

But there are always parts which I can't find in any template and are not in the html I would want them to be. Therefor I am asking. It is the same with the line including the author and the date of a post. I just can't find where the html code for this hides. Couldn't find it in any template.

Thank you for your reply.

econsultoria

teagle’s picture

Probably a bit late, and you've doubtless got it all sorted out now, but just from bitter personal newbie experience at 4am...

a) if when creating new content you leave a text field's Input Format set to Filtered HTML, even if you don't enter any text, it generates a br line break in $content that throws your layout.

b) if you copied phptemplate files over from another theme to build your own, look carefully at template.php if it exists, since this sometimes overrides other drupal functions, doing things like wrapping spans around links

c) as nevets said, the individual .module files will do a lot of formatting too... my own issue was with image.module, which puts a span around the img tag in order to hold the class info...

so there are a few new places to look!

nevets’s picture

You do not say of you are looking at page.tpl.php or node.tpl.php.

In page.tpl.php, $content will vary widely. In the 'simplest' case it is a formated node (as formated by node.tpl.php or a variant), to a list of nodes to a 'custom' layout that includes input forms, table output, etc. In short, for page.tpl.php, $content is varied and hopefully produced by a template (not always the case).

For node.tpl.php, $content reflects what the module put in $body or $teaser (depends on if you are viewing a teaser version of the node or not). For modules like page and story this should be just the body (teaser). For other modules though the content is a collection of information. Example, flexinode produces the node body by 'gathering' the data for all the fields, formatting it and placing it in the $body. You can for example write a template file for a specific flexinode type and over ride this. While this is generally true for any node based content, it is easier in some cases.

Note that modifying node.tpl.php (or a variant) will change the content page.tpl.php 'sees' when viewing a single node (or a list of nodes).

tiff’s picture

Ah, I misunderstood. You were asking "what else other than the text/html a user enters is in $content?"; luckily others more learned in Drupal than I were able to give an answer.

Apologies if my answer was incomplete/misleading.

-- T.

suydam’s picture

One of the things frustrating me this evening went like this:

I'm using PHPTemplate to build a custom theme. It's going to power a comletely static-looking web site and I'm really just using Drupal for CMS and for it's modules.

Problem: Every page comes out looking like a post on Slashdot or something: "Submitted by _____ ON ___" etc.

Turns out that stuff is confired in:
Administer->Themes->Global Settings

In there, you can set whether or not to show "Post info" on various node types.

I'm not sure why that's not in Admninister->Themes->my Theme->Configure but hey, I found it. :)

I'm just posting this so someone else might find it useful (since this thread is what kept coming up when I searched on $content)