Field Concatenation in Custom Detail Template

peterk900

Member
I have successfully created a 'starter' custom detail template by following Rob's video and with some forum guidance. I can retrieve fields from the data group and use html to place data as required. Very encouraging !

However I noticed that if I concatenate two fields with the php . operator each field appears on a separate line, even though the page mark-up has enough space to place both fields on the same line.

I tried using some regular expression code to strip out control characters but the result is the same.

Here is the code.

<?php
echo "<pre>";
//echo "zz1";
$contactus = $this->groups['Contact Details2'];
//print_r($contactus);
$elements = $contactus->elements;
print_r(array_keys($elements));
$name = $elements['first_name']->element;
$name1 = $elements['last_name']->element;
$name2 = $name . " " . $name1;
$string = trim(preg_replace('/\s+/', ' ', $name2));
print_r($name2);
//print_r($this->groups);
echo "</pre>";
?>
<div class="row-fluid">
<div class = "span8"><?php echo $string; ?> </div>
<div class = "span4"><?php echo $name1; ?> </div>
<div class = "span12"><?php echo "dddddddddjjjjjjjjjjjjdddddddddddddddddddddddd" . " ---- " . "bbbbbee" . $string; ?> </div>
<div class = "span12"><?php preg_replace('/[\x00-\x1F\x7F]/', '', $string); ?> </div>
</div>

fabrik0508c.png
The only two reasons for line breaks that I can think of are page mark up and control characters but it doesn't appear to be either. What do I need to do to display the first name and last name in the example like Peter Thomas . Thanks.
 
I have worked around this problem by doing the concatenation on a calculated field with this php snippet:

return {xg705_fb_contact_sample___first_name} . " " . {xg705_fb_contact_sample___last_name};

This works fine for names like Peter Thomas but fails for Peter Thomas-Morton giving a value of 0 and Peter Thomas:Morton or Peter Thomas Morton ( last name in italics ) - which return blank. The php code works fine stand-alone. I'd like to solve this not just for the custom template but also for using the calc plugin in other situations. Thanks.
 
I just ran into this same issue. Has anyone found a solution for this other than creating an extra calculated field; which I've had to do for the time being.
 
Last edited:
peterk900,

I use the following code in my calculated field and hyphenated names seem to work just fine:

$a = "{people___first_name} {people___last_name}";
return $a;
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top