I'm in the process of teaching myself php and learning how to use Display Suite. Also trying to harness the power of fields. So my mistake could be with one, two or all three of those areas.

For the article content type, I've created two fields — "field_stafftitle" and "field_writername". With Display Suite, I created a field called "byline_field" that I intend to combine other two with php.

The "byline_field" contains this snippet of php:

<?php
print "<strong>By #field_writername</strong>  |  <em>#field_stafftitle</em>";
print "<p>";

?>

I'm trying to produce this:

By John Smith | Contributing writer

But instead, I get this:

By #field_writername | #field_stafftitle

I realize this is probably a very basic php mistake, but to my shame, I haven't been able to figure it out. What am I doing wrong?

Comments

brianestadt’s picture

bump

ayesh’s picture

If you are not familiar with PHP, try Submitted By moduke tyat suits a little use case like yours.
In your PHP code, you have to split the code to print PHP array's variables.

print "<strong>By ".$main->subfield."</strong> | <em>".$main->subfield2"</em><p>" ;

this code is guaranteed to give a variable error unless you replace $main stuff with node, user or session variablrs.
If it's a node, see node.tpl.php api docs for available vars.

brianestadt’s picture

Unfortunately, Submitted By is compatible only with D 6.x. I'm working with D 7.x.