The problem appears to be the that the count is incremented even if media_type is something other than “Document”, in my case its “Image”. I assume that this has to do with EE and its parsing.
Have you tried swapping the PHP Parsing Stage setting in the template’s preferences?
Have you tried swapping the PHP Parsing Stage setting in the template’s preferences?
yes, when set to input the $output string isn’t created ( fair enough ) and you just get
<a href="http://{media}" class="{media_class}">{title}</a>
I’ve taken this over here – http://ellislab.com/forums/viewthread/99806/
Just in case this helps somebody I ended up with
<? $hasdocs = false ?>
{exp:weblog:entries limit="1"}
{related_entries id="rel_media"}
<? if ( "{media_type}" == "Document") { $hasdocs=true; } ?>
{/related_entries}
{/exp:weblog:entries}
<? if ( $hasdocs ) { ?>
<? } ?>
And yes I do need to do a second pass to actually get the document list. The trick seems to be that you need to do the conditional in PHP.
I’ve implement this extension to my client’s website and so far so good, except that they have a total of 900+ and increasing (its a books list) entries and they have to choose 10-15 from that list each month for a bestseller entry.
Is there a way I can auto collapse the list group?
Hi Brandon. Great extension! But I need little help with following issue.
Here is common example using Playa:
{if my_related_entries}
{related_entries id="my_related_entries"}
{media_url}
{/related_entries}
{/if}
Output will be e.g.:
/files/media-file_1.flv
/files/media-file_2.flv
/files/media-file_3.flv
/files/media-file_4.flv
I need to detect, if there is only one related entry or more than one. So system need to know:
Explanation: I’m building related videos under my entries using JW player and these conditionals are needed for achieve to display only video player (if there is assigned only one video) or video player + playlist (if there are assigned more than one video).
I’d like to welcome any build-in conditions or some PHP hack. {if} {if:else} conditionals doesn’t work inside {related_entries} tags.
Something like this with PHP on output should work:
{if my_related_entries}
<?php $count = 0; ?>
{related_entries id="my_related_entries"}
<?php $count++;
if ($count == 2) {
echo 'playlist start code';
}
if ($count > 1) {
echo 'playlist item code {media_url}';
}
elseif ($count == 1) {
echo '{media_url}';
}
?>
{/related_entries}
<?php if ($count > 1) {
echo 'playlist end code';
?>
{/if}
Playa 1.2.3 is out!
Changes include: - Playa now fully supports my just-released Gypsy extension - Moved all language to language/english/lang.playa.php for easier localization - Stopped bundling LG Addon Updater (but it’s still a recommended download!)
I just downloaded Playa 1.3.1 and enabled it but am having trouble getting it to work.
I’m running MSM, PHP5, EE 1.6.4, and the Playa extension is enabled. Changing the field to a simple related entry works. Here’s my code:
{exp:weblog:entries weblog="my_weblog_id" orderby="title" sort="asc" disable="member_data|trackbacks|pagination" search:my_custom_field="no"}
<h4>{title}</h4>
{body}
{related_entries id="my_field_id"}
<h6>{title}</h6>
{/related_entries}
{/exp:weblog:entries}
When I load the page nothing displays as a related entry. Any ideas?
Any suggestions for troubleshooting this? I’m running PHP 5.2.6, EE 1.6.6, and Playa 1.3.2. Normal related entries are working just fine. I tried disabling all extensions and enabling them again. I also tried disabling just Playa and enabling it again. I’m able to make the related selections in the weblog entry form. My only trouble is getting the related info to display in my query.
Any help would be greatly appreciated. This extension is extremely valuable.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.