I was having this discussion with someone the other day, about enabling PHP on templates to do what you need to do. You almost get the idea you can’t do it - or shouldn’t do it - on an EE template. That’s bogus, of course, and I find that in many cases, it’s essential to do something with PHP!
Well, I’ve found the problem:
Here is part of the print out for the template object $TMPL:
[related_markers] => Array
(
[0] => doc_services" limit="1
[1] => doc_services
[2] => doc_locations
[3] => doc_locations
)
Any thoughts on how to fix the field name regular expression? I’m not sure where to go from here, but will trudge on.
Thanks! Sean
[var_single] => Array
(
[title] => title
[doc_display_name] => doc_display_name
[doc_title] => doc_title
[service_display_name] => service_display_name
[location_display_name] => location_display_name
[doc_services" limit="1] => doc_services" limit="1
[doc_services] => doc_services
[doc_locations] => doc_locations
)
… looks broken also.
Looking at the regex for the {related_entries} tag:
preg_match_all("/".LD."related_entries\s+id\s*=\s*[\"\'](.+?)[\"\']".RD.
"(.+?)".LD.SLASH."related_entries".RD."/is", $chunk, $matches)
As I read this I see the regular expression is missing the extra attributes of the tag, like limit=”” and offset=”“. So, this is on purpose? There is no ability to do a limit or an offset? Is this by design?
Any answers would be appreciated.
Thanks! Sean
Okay, that makes sense now. Hopefully in EE 2.0 there will be the ability to do this natively.
My workaround does involve PHP: I simply created a count, tested for the first value, then incremented the value. Simple stuff, but would be “cleaner” if it were all EE. 😊
Thanks! Sean
Hi all,
I am using some code to pull out entry_ids using Playa. Now I thought that it would pull them out in the order I set them in Playa but instead it is pulling them out in order of entry_id.
Here is my code -
{embed="includes/exhibitions_selected_works_item" gallery_id="0{related_entries id="exhibitions_related_artist"}|{entry_id}{/related_entries}"}
which embeds this -
{exp:weblog:entries entry_id="{embed:gallery_id}" dynamic="off" disable="categories|member_data|trackbacks"}
etc etc
It is throwing out the following (test output)
William Zorach - 298
Robert Motherwell - 234
Michael Goldberg - 158
Giorgio Cavallon - 125
Albert Bloch - 87
Emil James Bisttram - 86
Romare Bearden - 78
Hans Hofmann - 53
Which is different to the order I have set in Playa.
I’m having some trouble with some related entries not showing up. When I output my playa field I am getting some kind of database table reference in square brackets, followed by the title of the related entry.
The numbers preceded by an exclamation mark are not showing. Can anybody please tell me what the exclamation mark refers to, as it seems that getting rid of this is the answer to my problems.
The format of the non-displaying related entries is this: [!1234] Entry Title
Ones that look like this are successfully outputted by the related_entries loop: [1234] Entry Title
Ok I have a solution for the custom status thing but it’s not quite as refined as you might want. Basically it allows you to assign any entry as long as it’s not closed.
Find the code below in the ext.playa.php file (Do a search for ‘status’ and it should be the first thing you find -
// --------------------------------
// Assemble Rel Reference
// - returns "[1234] Child Title"
// --------------------------------
Look out for this line -
$closed = ($status AND $status != 'open') ? '!' : '';
and change it to -
$closed = ($status AND $status == 'closed') ? '!' : '';
In the control panel, the entry you choose will still turn grey but it will be available to view in the template!
Be sure to only use the default status group (I’m not sure if this is importnat but I am as I don’t have time to test) and remember Playa will now consider all Status options except for Closed.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.