• I have a field called ‘website’, which I’ve set as a “Link field”. I know that including <?php $record->print_value(‘website’) ?> in my custom template prints ‘website’s link text, linked to ‘website’s url. I like this for the details page, which I’ve linked to as “more info” from the main list.

    What I would like to do in my custom template, however, is to have a link where the text is the participant’s name and the url is their website. In other words, I want to know what I should replace [STUFF] with to grab just the url from ‘website’ in the following:
    <a href="<?php $record->[STUFF] ?>"><?php $record->print_value( 'first_name' ) ?> <?php $record->print_value( 'last_name' ) ?></a>

    Thank you!

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

    (@xnau)

    Yes, you can do this, the code is pretty simple.

    First $this->participant_values is an array of all the values in the record, but the “link” field is stored as a serialized array (as url, linktext), so it needs to be decoded….so, if your link field is named “website” you’d do it like this:

    $link_info = maybe_unserialize( $this->participant_values['website'] );
    $url = $link_info[0];
    Thread Starter zdaugherty

    (@zdaugherty)

    Thank you for your fast response! Maybe this is a novice follow-up, but I am just learning php…

    This produces only the last participant’s website URL (last as in last in the sorted search, not last in the database). To be clear, adding your code to the section where the rest of the participant’s info gets printed, followed by an
    echo $url, or just echo maybe_unserialize( $this->participant_values['website'] )[0]; prints the last participant’s URL amongst every participant’s information. Ideas?

    Plugin Author xnau webdesign

    (@xnau)

    Ok, I don’t know what you’re trying to do, and I can’t really tell you how to do it, that will be up to you. The code I gave is supposed to be in the record loop, so it will use the data for the current record.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Using URL from “Link field” in custom template’ is closed to new replies.