I have just created my own module and need a bit of help displaying the content on the front end. I currently have some template tags {exp:address_book:contact}{/exp:address_book:contact} and within them a series of variables; {ab_name}, {ab_contact_number} etc.

These are laid out in the site templates as so:

  <table class="contact_info">
    <td class="label">Title</td>
    <td class="label">Company</td>
    <td class="label">Name</td>
    <td>{ab_first_name} {ab_last_name}</td>
    <td>Company Tel No.</td>
    <td class="label">Contact No.</td>
    <td colspan="2">{ab_address_1}</td>
    <td class="label">Email</td>
    <td><a href="mailto:{ab_email}">{ab_email}</a></td>
    <td colspan="2">{ab_address_2}</td>
    <td class="label">Facebook</td>
    <td><a href="{ab_facebook}" target="_blank">View page</a></td>
    <td colspan="2">{ab_city}</td>
    <td class="label">Twitter</td>
    <td><a href="{ab_twitter}" target="_blank">View feed</a></td>
    <td colspan="2">{ab_county}{if ab_country}, {ab_country}{/if}</td>
    <td class="label">LinkedIn</td>
    <td><a href="{ab_linkedin}" target="_blank">View profile</a>
      <td colspan="2">{ab_post_code}</td>

Ideally I need to find a way to output this data in a single tag, rather than having to specify the layout in the site template files. Is there any way to do this?

Here is my function in my mod.module.php file:

public function contacts()

    $contact_id = $this->EE->TMPL->fetch_param('contact_id');

    $tagdata = $this->EE->TMPL->tagdata;

    if( $contact_id ) {
        $this->EE->db->where('id', $contact_id); 
    $this->EE->db->order_by('first_name', 'asc');

    $query = $this->EE->db->get();

    if ($query->num_rows() == 0)
        return $this->EE->TMPL->no_results();

    foreach ( $query->result_array() as $row ) {
        $variables[] = array(
            'ab_title' => $row['title'],
            'ab_first_name' => $row['first_name'],
            'ab_last_name' => $row['last_name'],
            'ab_personal_number' => $row['personal_contact_number'],
            'ab_company' => $row['company'],
            'ab_company_contact_number' => $row['company_contact_number'],
            'ab_address_1' => $row['address_street_1'],
            'ab_address_2' => $row['address_street_2'],
            'ab_city' => $row['address_city'],
            'ab_county' => $row['address_county'],
            'ab_country' => $row['address_country'],
            'ab_post_code' => $row['address_post_code'],
            'ab_website' => $row['website'],
            'ab_email' => $row['email_address'],
            'ab_facebook' => $row['facebook'],
            'ab_twitter' => $row['twitter'],
            'ab_linkedin' => $row['linkedin'],

    return $this->EE->TMPL->parse_variables( $tagdata, $variables );


Any help would be greatly appreciated, thank you.

  • Doi! Turns out you can just return any data from the function and it appears on the front end... Sep 10, 2014 at 14:08

1 Answer 1


The best coding practice is to utilize view files in order to achieve that.

  • Ah! This helps me greatly as I ran into some troubles just returning straight from the function. I didn't realise you could show vies to the front end either. Thanks for your help! Sep 11, 2014 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.