• Resolved lori-wba

    (@lori-wba)


    This is a great plug-in! Thanks!

    I’ve searched for an answer to this but can’t find anything: Can I hyperlink one field (a person’s name, for instance) to the URL contained in another field (that person’s website)?

    I think this would *not* be the “Single Record Field” [pdb_single] because I do not want all records to link to the same page. I need them to link to various URLs as specified in another field in the database.

    Thanks again!

    http://ww.wp.xz.cn/extend/plugins/participants-database/

Viewing 1 replies (of 1 total)
  • Plugin Author Roland Barker

    (@xnau)

    OK, well this is slightly complicated, but if you’re good with PHP, no problem. Create a custom template for your list (instructions here) then, set up your code to add the link to the desired field. Inside the top loop in the template, you can get the value for any field of a record with “$this->record->fields->FIELD_NAME->value” replacing “FIELD_NAME” with the name of the fields you want to get the value of.

    You would put something like this in your template after the line that has “$this->the_field()”. Let’s say you wanted to put the link on the “first_name” field, and the URL is coming from a link field named “website”. Link fields are stored as arrays where the first element is the URL, so we have to unserialize it to get the array.

    <?php if ($this->field->name == 'first_name') {
       $link_array = unserialize($this->record->fields->website->value);
       $this->field->value = '<a href="'.$link_array[0].'">'.$this->field->value.'</a>';
    } ?>

    Note that field values will only be available for fields that have been set to display in the list.

Viewing 1 replies (of 1 total)

The topic ‘Hyperlink one field using another field's data’ is closed to new replies.