I'm making several HTML popups that always follows a defined template.
Since there is a template (header,content,example table,more button), I thought I can save a lot of recurring html by passing the data to a wrapper function like so:
$device_popup_data = array(
'header' => 'Header text',
'content' => 'some text<span style ="bold"> Some more text</span>',
'example' => '<table><tbody><tr><td> A lot of text here, multi lined and messy',
'more' => '',
);
echo theme_uxt_expanded_popup($device_popup_data);
function theme_uxt_expanded_popup($data){
$head = isset($data['head'])?$data['head']:'';
$content = isset($data['content'])?$data['content']:'';
$example = isset($data['example'])?$data['example']:'';
$more_html = isset($data['more'])?$data['more']:'';
$output= '<div class = "expandedTooltip">';
$output.= '<h1>'.$head.'</h1>';
$output.= '<p>'.$content.'</p>';
if(!empty($more)){
$output.= '<a class = "popupShowMore"><p>'.$more.'</p></a>';
}
$output .= '</div>';
return $output;
}
This seemed like a great idea, until I have seen that some of these fields, like the example
field, may contain around 100 lines of HTML.
Pushing these long strings into the example variable seems to make very unreadable code. Something like this :
$device_popup_data = array(
'header' => 'Header text',
'content' => 'some text<span style ="bold"> Some more text</span>',
'example' => '<table><tbody><tr><td> A lot of text here</td>,<td> multi lined and
messy, and if any one</td>
<td>wants to change this string it will be very hard</td>
Real string is much longer ... </table>',
'more' => '',
);
Do you know of an efficient and readable way of doing something like this?