• Hello and thank you for the plugin.

    I’m trying to use a shortcode to show a single record by last name. I couldn’t find the documentation for using “term” but I did step through the code.

    I believe it expects something like [pdb_single record_id=smith term=last_name ], but by the time execution reaches the essential part of PDb_Single::__construct() (“determine the ID of the record to show”), the function at Participants_Db::print_single_record() has altered record_id from ‘smith’ to = FALSE.

    It seems to ignore its $params and calls self::get_record_id_by_term() with a hard-coded ‘id’ which will never find ‘smith’ or any string in the ID column.

    This essentially negates any attempt at using term=___ in the shortcode.

    I wouldn’t have enough broader context to unravel what “should” be the patch without breaking something else (or if I’m not even using the correct shortcode syntax), but just wanted to point this out in case you choose to fix it at some time.

    thanks again!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter viveredesign

    (@viveredesign)

    Here’s my humble suggested fix in the Participants_Db class:

    /**
       * prints a single record called by [pdb_single] shortcode
       *
       * @param array $params the parameters passed in by the shortcode
       * @return string the output HTML
       */
      public static function print_single_record( $params )
      {
    
        // alias the 'id' attribute for backwards compatibility
        if ( isset( $params['id'] ) & !isset( $params['record_id'] ) ) {
          $params['record_id'] = $params['id'];
          unset( $params['id'] );
        }
        // PDb_Single::__construct is where 'term' is handled
        if ( isset( $params['record_id'] ) && !isset($params['term'])) {
          $params['record_id'] = self::get_record_id_by_term( 'id', $params['record_id'] );
        }
    
        return PDb_Single::print_record( $params );
      }
    Plugin Author xnau webdesign

    (@xnau)

    Thanks for letting me know about this…I appreciate you taking a closer look and sharing what you found, made it easy to find the problem.

    I’ll be including a fix for this in the next update. I updated that function by removing the unneeded code that finds the record ID:

      /**
       * prints a single record called by [pdb_single] shortcode
       * 
       * @param array $params the parameters passed in by the shortcode
       * @return string the output HTML
       */
      public static function print_single_record( $params )
      {
        // alias the 'id' attribute for backwards compatibility
        if ( isset( $params['id'] ) & !isset( $params['record_id'] ) ) {
          $params['record_id'] = $params['id'];
          unset( $params['id'] );
        }
    
        return PDb_Single::print_record( $params );
      }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode: Single record lookup by term not working?’ is closed to new replies.