1

So I'm running into a issue and I'm completely stuck. I'm trying to use Php in the playa tags to get my associations. But, no matter what I do, I always get a mysql error, as if the php variable isn't set yet. In my template, I even created a plugin, to set that variable to the entry_id that I need to associate on.

Here's some sample code:

This is my plugin, I can echo out $categoryEntryId and the value is correct:

$categoryEntryId = '{exp:getcategoryentryid category="{segment_3}" parse="inward"}';

Below is some sample code where the mysql error is happening.

{exp:playa:parents entry_id="<?php echo $categoryEntryId;?>" backspace="10"}

This will result in the following error:

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 2

SELECT DISTINCT(rel.parent_entry_id) AS entry_id FROM exp_playa_relationships rel WHERE rel.child_entry_id =
Filename: third_party/playa/mod.playa.php

Line Number: 701

Now, if I change it to the following, it works fine.

{exp:playa:parents entry_id="328" backspace="10"}

Anyone have any ideas on how I can resolve this issue? I started down the path on using the plugin, because earlier today, I was doing a query within the template, but had an issue with a naming conflict on the {title} tag for the result I just searched on, and the content within the {exp:playa} which also had to use the {title} tags.

2
  • Playa has a var_prefix parameter for name spacing fields like {title}. Have you tried that? Mar 16 '13 at 21:12
  • Actually, this works just great, now I'm not having the naming conflict at all. Looks like my version of Playa I'm working on was outdated, had the Tech director get the latest version, all is working!
    – Whnunlife
    Mar 20 '13 at 15:28
1

What I'd suggest instead is that you use your plugin as a tag pair with one variable - category_entry_id - then put your Playa tag inside of it.

{exp:getcategoryentryid category="{segment_3}" parse="inward"}
    {exp:playa:parents entry_id="{category_entry_id}" backspace="10"}
        ...
    {/exp:playa:parents}
{/exp:getcategoryentryid}

Right now your plugin probably does this:

$this->return_data = $categoryEntryId;

Instead, you need to do this:

$this->return_data = $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, array('category_entry_id' => $categoryEntryId));
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.