ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How can you use PHP with a Relationship field?

July 06, 2014 5:36pm

Subscribe [0]
  • #1 / Jul 06, 2014 5:36pm

    gcylinder

    49 posts

    I’m having trouble embedding PHP into a template and having anything on the page render, and I assume it’s because I’m working with a Relationship field.

    Just as an example, this works:

    {portfolio_projects}
    <span class="date"><?php echo("Client A"); ?></span>
    {/portfolio_projects}

    and this works:

    {portfolio_projects}
    <span class="date">{portfolio_projects:client_name}</span>
    {/portfolio_projects}

    but this does not (I just get a blank page with empty <html> and <body> tags):

    {portfolio_projects}
    <span class="date"><?php echo({portfolio_projects:client_name}); ?></span>
    {/portfolio_projects}

    So I reckon I’m doing something wrong. Help?! (BTW, I’ll be needing to use PHP on my template to do a regex/preg_replace on strings.)

  • #2 / Jul 06, 2014 9:06pm

    gcylinder

    49 posts

    Ugh. Turns out I’m missing quotation marks when I try to echo the Relationship field output.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases