Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter borjawebs

    (@borjawebs)

    What exactly does the “proper retrieve method” entail?

    Thread Starter borjawebs

    (@borjawebs)

    Here’s a little value add. Helps to unify the phone number format where various formats may be used:

    $default_area_code = '555';
    
       $phone = unserialize($row->phone_numbers);
       $phone  = array_pop($phone);
       $phone = $phone['number'];
    
       // Filters
       $length = strlen(preg_replace('/[^\d]/', '', $phone));
    
       // No area code
       if($length == 7)
       $phone = $default_area_code . '-' . $phone;
    
       $filtered = preg_replace('/^\(?(\d+)\)?\s*\-*(\d+)\-?(\d+)(\w*)(\d*)/', '(\1) \2-\3 \4\5', $phone);
       // $phone .= '<!-- Filtered as '.$filtered.'-->';
       $phone = $filtered;
       $row->phone = $phone;
    Thread Starter borjawebs

    (@borjawebs)

    Alright, so seeing that this feature is not going to be available soon, allow me to contribute to this part of the Connections plugin.

    A simple WordPress Page Template that simply displays listings from the Connections plugin’s database and renders a category sorted view. This is the minimal amount of coding required to do this, allowing you flexibility to modify any way you want.

    Please share:

    <?php
    /*
    Template Name: Business Directory (Connections)
     */
    
    $terms = array();
    $q = mysql_query('SELECT * FROM wp_connections_terms');
    while($row = mysql_fetch_object($q)) {
       $terms[$row->term_id] = array(
          'meta' => $row,
          'listings' => array()
       );
    }
    
    $q = mysql_query('
       SELECT *
       FROM wp_connections
       INNER JOIN wp_connections_term_relationships ON wp_connections_term_relationships.entry_id = wp_connections.id
       INNER JOIN wp_connections_term_taxonomy ON wp_connections_term_taxonomy.term_taxonomy_id = wp_connections_term_relationships.term_taxonomy_id
    ');
    while($row = mysql_fetch_object($q)) {
       $email = unserialize($row->email);
       $email = array_pop($email);
       $email = str_replace('@', ' (at) ', $email['address']);
       $row->email = $email;
    
       $phone = unserialize($row->phone_numbers);
       $phone  = array_pop($phone);
       $row->phone = $phone['number'];
    
       array_push($terms[$row->term_id]['listings'], $row);
    }
    ?>
    <?php get_header(); ?>
    <style type="text/css">
    table.directory {
    	font: 12px Arial, Tahoma, sans-serif;
    }
    
    table.directory a {
    	color: #369;
    }
    
    table.directory tr th,
    table.directory tr td {
    	vertical-align: middle;
    	text-align: left;
    	padding: 5px;
    }
    
    table.directory tr th {
    	padding-top: 25px;
    	border-bottom: 1px solid #def;
    	color: #369;
    
    	font-size: 14px;
    }
    table.directory tr td {
    color: #555;
    }
    table.directory tr:hover td {
    	background: #f5f5ff;
    
    }
    
    </style>
    
    <div class="span-24" id="contentwrap">
    
        <?php get_sidebars('left'); ?>
    
        <div class="span-18">
            <div id="content">
             <h2>Business Directory</h2>
             <table class="directory" cellspacing="0">
             <tbody>
                <?php foreach($terms as $t) : ?>
                <tr>
                <th colspan="3" style="padding-top: 0;"><?php echo $t['meta']->name; ?></th>
                </tr>
                   <?php foreach($t['listings'] as $l) : ?>
                   <tr>
                   <td align="left" valign="top"><?php echo $l->organization; ?></td>
                   <td align="left" valign="top" nowrap="nowrap"><?php echo $l->phone; ?></td>
                   <td align="left" valign="top"><?php echo $l->email; ?></td>
                   </tr>
                   <?php endforeach; ?>
                   <tr><td colspan="3" style="padding: 10px 0;"></td></tr>
                <?php endforeach; ?>
                </tbody>
              </table>
            </div>
        </div>
    </div>
    <?php get_footer(); ?>

    Thread Starter borjawebs

    (@borjawebs)

    You think standard MySQL queries and joins would be sufficient for just rendering a view like this, organized by categories? e.g. setting it as a page template and leave it like that?

    Thread Starter borjawebs

    (@borjawebs)

    Will this be a feature supported soon?

Viewing 5 replies - 1 through 5 (of 5 total)