• I’m using Participants Database to maintain a jobs database. I’m using [pdb_list] to list the jobs on the front end. I want the user of this page to be able to click on an Edit field for a given job in the list and go to the edit page for that job. I want to pass the variable for the record id or the job number in the url but I can’t figure out how to do it without hard coding a particular number (id=46, for example).

    This, obviously, takes me the edit page for record id 46:

    /wp-admin/admin.php?page=participants-database-edit_participant&action=edit&id=46

    I want to substitute ’46’ with a variable name. I’m not a php programmer so I think I just haven’t set up the variables correctly.

    I’d appreciate any help…

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter adelaidelk

    (@adelaidelk)

    I tried that and couldn’t make it work. I’ll try again.

    Thread Starter adelaidelk

    (@adelaidelk)

    I’m using a child theme and I couldn’t figure out where to put the custom template. I’ll keep working at it.

    Thread Starter adelaidelk

    (@adelaidelk)

    So I added the Edit Record Link as described in the above article, and this time it all worked. But the link created just re-displays the list page instead of going to the edit page for that record.

    Here’s the url of the list page:
    /index.php/list-jobs-2/
    and the Edit link for one of the listed jobs is:
    /index.php/list-jobs-2/?pid=8IUTG

    The pid in the link for each job is different but clicking on it just redisplays the list page.

    My custom template is pdb-list-edit.php, I put it in the templates folder in my child-theme folder, and on the list page I used the shortcode [pdb_list template=edit]

    You need to set the “participant record page” setting under the “Record Form Settings” tab.

    Thread Starter adelaidelk

    (@adelaidelk)

    Thanks. If that was in the doc anywhere I missed it, but all is working now.

    Thread Starter adelaidelk

    (@adelaidelk)

    Now I want to add the edit link to a page that uses the pdb_single shortcode to display a single record. Is this possible? I think I need to make changes to pdb-single.php but I don’t know exactly what or where.

    this article explains how to do that:

    Adding an Edit Record Link to the Frontend List

    Thread Starter adelaidelk

    (@adelaidelk)

    I’ve done that and have it working on pdb_list page but it’s not working on pdb_single. When a single record is displayed I want to include a link to the edit page for that record.

    It works pretty much, but not exactly, the same way. What are you doing on your custom template for the single shortcode?

    Thread Starter adelaidelk

    (@adelaidelk)

    In the template itself I don’t know what to do: I want to display most of the fields and then the edit link. So all I want to do to customize the default single template is make the edit link active, to bring the user to the edit page for that record.

    Here’s what I have that’s not working:

    <div class="wrap <?php echo $this->wrap_class ?>">
    
      <?php while ( $this->have_groups() ) : $this->the_group(); ?>
    
      <div class="section <?php $this->group->print_class() ?>" id="<?php echo Participants_Db::$prefix.$this->group->name ?>">
    
      <?php /*?> <?php $this->group->print_title( '<h2 class="pdb-group-title">', '</h2>' ) ?><?php */?>
    
        <?php $this->group->print_description() ?>
          <?php $record = new PDb_Template($this); ?>
    
          <?php while ( $this->have_fields() ) : $this->the_field();?>
    
           <?php
            /*
             * put the edit link URL into the link property of the field
             */
            if ($this->field->name == 'edit_link') {
              $this->field->link = $record->get_edit_link();
            }
            $this->field->print_value();
            ?>

    here’s my shortcode:
    [pdb_single template=custom, fields="job_number, employer,job_type, practice_area, job_title, job_description, region,state,whats_new,date_posted,practice_area2, edit_link"]

    OK, what exactly is happening? I don’t see the whole code, but I don’t see anything here that would break it.

    You do want to set up the template class outside of the loop, though…put your

    <?php $record = new PDb_Template($this); ?>

    at the top of your template so it only get executed once.

    Thread Starter adelaidelk

    (@adelaidelk)

    I finally got it to work. Here’s all the code in my custom pdb-single-custom.php page (except for the $exclude stmnt). I included the check for the edit_link field in the <?php while have_fields stmnt instead of in its own <?php stmnt, and I put the <?php $record = new PDb_Template($this); ?> right after the opening <div>.

    <div class="wrap <?php echo $this->wrap_class ?>">
    <?php $record = new PDb_Template($this); ?>
    
      <?php while ( $this->have_groups() ) : $this->the_group(); ?>
    
      <div class="section <?php $this->group->print_class() ?>" id="<?php echo Participants_Db::$prefix.$this->group->name ?>">
    
        <?php //$this->group->print_title( '<h2 class="pdb-group-title">', '</h2>' ) ?>
    
        <?php // $this->group->print_description() ?>
    
          <?php while ( $this->have_fields() ) : $this->the_field();
    	  /*
             * put the edit link URL into the link property of the field
             */
         if ($this->field->name == 'edit_link') {
              $this->field->link = $record->get_edit_link();
            }
           		   // skip any field found in the exclude array
              if ( in_array( $this->field->name, $exclude ) ) continue;
    
              // CSS class for empty fields
    					$empty_class = $this->get_empty_class( $this->field );
    
          ?>
    
        <dl class="<?php echo Participants_Db::$prefix.$this->field->name.' '.$this->field->form_element.' '.$empty_class?>">
    
          <dt class="<?php echo $this->field->name.' '.$empty_class?>"><?php $this->field->print_label() ?></dt>
    
          <dd class="<?php echo $this->field->name.' '.$empty_class?>"><?php $this->field->print_value() ?></dd>
    
        </dl>
    
        	<?php endwhile; // end of the fields loop ?>
          </div>
    
      <?php endwhile; // end of the groups loop ?>
    
    </div>

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

The topic ‘participants database plugin passing database variable in url’ is closed to new replies.