In my content template I have two fields (date and teaser) and I want to show them like this:
29-03-2008 - Here goes the text of the teaser

So far, I haven't been able to do this. I get a line break between the two elements. When I look in the source code of the generated page, I see the second element (the teaser) has

around it. Does anyone know if/how I can get my teaser the way I described above?

Comments

jrglasgow’s picture

the line break is actually html paragraph tags

<p>Teaser</p>

there are two ways to do this

<?php
  $temp_teaser = str_replace('<p>', '', str_replace('</p>', '', $teaser));
  print date('m-d-Y', node->created) .' '. $temp_teaser;
?>

This will replace the beginning(<p>) and ending(</p>) paragraph tags and replaces them with an empty string('').

<?php
  $temp_teaser = strip_tags($teaser);
  print date('m-d-Y', node->created) .' - '. $temp_teaser;
?>

The strip_tags() function removes html tags from the string, take a look at the php.net manual page, you can have it strip some tags but leave some alone.

bergco’s picture

Thanks! Somehow I got an error message, but with your hints I constructed this:
print format_date($node->created,'custom','d-m-Y') - print strip_tags($node->teaser)
and it works fine! Thanks again. Still got a lot to learn...

jrglasgow’s picture

Status: Active » Closed (fixed)