• It would be extremely useful to be able to include a field, viewable and clickable in a display of the “pdb_list” shortcode, that would provide access to a full records – just as the EDIT box on the admin page does.

    In the implementation I’m mounting, I use the pdb_list shortcode to generate lists for each of my “reps” – a dozen or so people that have records assigned to them for follow-up. Each pdb_list is in a separate DIV on the pdb_list page, filtered by a “rep” field. My reps find it easy to work from such a filtered listing – much easier than working from the admin screen, and having to re-filter the master list for his or her own clients after each edit of a record.

    Is there some way to do this — or perhaps an easier way to accomplish my overall objective?

    Many thanks.

    http://wordpress.org/plugins/participants-database/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author xnau webdesign

    (@xnau)

    The way to do this is to create a custom template for your list (explained here) and then add your link to the participant record page. First, you need to create a field that will provide something to click on…let’s say it’s a read-only text field named ‘edit’ In your list template, add this after the line that has “$this->the_field()”

    <?php if ($this->field->name == 'edit' ) {
    $participant_data = Participants_Db::get_participant($this->record->record_id);
    $record_edit_link = Participants_Db::add_uri_conjunction(get_permalink(Participants_Db::$plugin_settings['registration_page'])) . "pid=" . $participant_data['private_id'];
    $this->field->value = '<a href="' . $record_edit_link . '">edit</a>';
    } ?>
    Thread Starter AlbertJPeters

    (@albertjpeters)

    I must be missing something. After executing the steps below, I get (for example) the following displaying on my [pdb_list] page, instead of the defaulted word, “VIEW”:

    edit

    Clicking on the link takes me to that record, but in a view-only mode. What am I missing?

    My steps:

    – created a read-only field called EDIT with VIEW as its default. Made it sortable.

    – Copied pdb-list-detailed.php to my local machine. Edited it to include your insert below the “$this->the_field()” line. Saved the file.

    – Uploaded pdb-list-detailed.php to a directory under my plugin. I’m using “responsive” as my theme, and my directory under wordpress’s themes directory is responsive/themes/pdb-list-detailed.php.

    Plugin Author xnau webdesign

    (@xnau)

    Make sure you have the “Participant Record Page” setting pointing to the page with the [pdb_record] shortcode.

    The template has to go in a directory named “templates”

    Probably something like: wp-content/themes/responsive/templates/pdb-list-detailed.php

    The word “edit” is hard-coded into the code I gave you…you can replace that with the $this->field->value if you want it to pick up the default value of the field.

    Thread Starter AlbertJPeters

    (@albertjpeters)

    OK. No luck. So I did the following: (1) I did a fresh install of wordpress and your plugin, leaving fields unchanged. (2) created a read-only database field named “edit” and made it sortable. Also defaulted its value to “EDIT”. (3) Created a target page for the pdb_list shortcode. Created a new template based on “pdb-list-detailed.php” called “pdb-list-ajpeditable.php”. They are identical, except that the latter has your code snippet inserted. (4) Uploaded my new template to a subdirectory of my responsive theme called “templates”. (5) Completed configurations and double-checked checked my settings for pdb_record shortcode page. (6) Put the following shortcode on my “pdb_list” page: “[pdb_list template=”ajpeditable”].

    Still no luck! What I get is a column in my records listing that has a column heading called EDIT, but rather than a hyperlink for each record leading to an editable complete record, I get the following string:(this is the one for my 1st of 3 test records):

    edit

    I wish I could debug this myself, but can we fix my blindspot?

    Plugin Author xnau webdesign

    (@xnau)

    The key is this: “The word “edit” is hard-coded into the code I gave you…you can replace that with the $this->field->value if you want it to pick up the default value of the field.”

    Here it is with the change I suggested you try:

    <?php if ($this->field->name == 'edit' ) {
    $participant_data = Participants_Db::get_participant($this->record->record_id);
    $record_edit_link = Participants_Db::add_uri_conjunction(get_permalink(Participants_Db::$plugin_settings['registration_page'])) . "pid=" . $participant_data['private_id'];
    $this->field->value = '<a href="' . $record_edit_link . '"><?php echo $this->field->value ?></a>';
    } ?>
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Accessing full records (read-write) from pdb_list’ is closed to new replies.