WordPress.org

Ready to get started?Download WordPress

Forums

Connections Business Directory
[resolved] [Plugin: Connections] Listing incorrectly displayed under wrong category (10 posts)

  1. borjawebs
    Member
    Posted 1 year ago #

    We created a listing for a business under two categories. However, when we go back to look for them in the display view labeled "Business Directory," it is not under the categories we specified. A closer look revealed it was actually showing up in a totally separate, unrelated category.

    The display view is just a page with this in it:

    [connections order_by='category']

    Any ideas as to what's going on? Here are the listing details:

    URL: http://www.pvchamber.org/membership-directory
    Business: Designs with Hope
    Categories set to: Advertising, Graphic Design / Advertising
    But instead shows up in: Home Health Services

    http://wordpress.org/extend/plugins/connections/

  2. shazahm1
    Member
    Plugin Author

    Posted 1 year ago #

    I actually do not think I can help. I'd have to have a temp access to see what you're doing. The only thing I can say is that the shortcode [connections order_by='category'] is not valid. There is no option to sort by category.

  3. borjawebs
    Member
    Posted 1 year ago #

    Will this be a feature supported soon?

  4. shazahm1
    Member
    Plugin Author

    Posted 1 year ago #

    Not likely. I would more likely add a group_by option so one can group by different objects and then order them within that grouping, but I would not expect for this feature to be implemented soon.

  5. borjawebs
    Member
    Posted 1 year ago #

    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?

  6. borjawebs
    Member
    Posted 1 year ago #

    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(); ?>
  7. borjawebs
    Member
    Posted 1 year ago #

    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;
  8. shazahm1
    Member
    Plugin Author

    Posted 1 year ago #

    @borjawebs

    Yes, joins are exactly how this would be accomplished as you demonstrated. However, the above code was not incorporated within the proper retrieve method and as such bypasses all the features built-in to that code which builds the queries for Connections. Probably most importantly, it completely bypasses the public/private/unlisted visibility and approved/pending status of entries and their associated data. Adding this to the proper retrieve method is not so simple because of the many other variables that have to be taken into consideration which requires a lot of testing. Breaking that method would be unacceptable as it would break 10's of thousands of directories.

    I am glad you found a solution that worked for you, but unless others know precisely what they are doing, I can not recommend using the above code. I'm sure you can appreciate that.

  9. borjawebs
    Member
    Posted 1 year ago #

    What exactly does the "proper retrieve method" entail?

  10. shazahm1
    Member
    Plugin Author

    Posted 1 year ago #

    @borjawebs

    Look in the class.retrieve.php under the retrieve method.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic