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.

Help with some custom SQL and/or PHP

November 23, 2010 11:22am

Subscribe [3]
  • #31 / Dec 02, 2010 3:32pm

    lebisol

    2234 posts

    I just noticed…What is your snippet name? Is it {exec_club}?
    If so then it can not have itself as variable, at least not in the last code you posted.
    the part of….entry_id=”{exec_club}”

    {exp:member:custom_profile_data}
    
    {exp:channel:entries channel="clubs" dynamic="no" entry_id="{exec_club}"}
           
                 {club_teams}{entry_id}|{/club_teams}
    
    {/exp:channel:entries}
    
    {/exp:member:custom_profile_data}

    Maybe a typo?

  • #32 / Dec 03, 2010 5:41am

    Scott Boyde

    208 posts

    I just noticed…What is your snippet name? Is it {exec_club}?
    If so then it can not have itself as variable, at least not in the last code you posted.
    the part of….entry_id=”{exec_club}”

    {exp:member:custom_profile_data}
    
    {exp:channel:entries channel="clubs" dynamic="no" entry_id="{exec_club}"}
           
                 {club_teams}{entry_id}|{/club_teams}
    
    {/exp:channel:entries}
    
    {/exp:member:custom_profile_data}

    Maybe a typo?

    I changed the name of the snippet to club_id, but as you said snippets have to be static.

  • #33 / Dec 03, 2010 5:47am

    Scott Boyde

    208 posts

    If you don’t mind enabling php you could do this:

    {exp:channel:entries channel="teams" dynamic="no"}
        <?php
            $list = explode("|","{exec_club}");
            $current_entry = "{entry_id}";
            $in_list = in_array($current_entry,$list) ? TRUE : FALSE;
        ?>
        {if "<?php echo $in_list; ?>"}
            <h3>{title}</h3>
    <p>        {embed="a_new_template_for_reverse_related_entries" entry_id="{entry_id}"}<br />
        {/if}<br />
    {/exp:channel:entries}

    You’ll need to fetch the reverse_related_entries via an embed because of parse order, but it should work…

    Embedded template:

    {exp:channel:entries channel="teams" dynamic="no" entry_id="{embed:entry_id}"}
        {reverse_related_entries sort="desc" orderby="title"}        
            <h4>{title}</h4><p>        <br />
        {/reverse_related_entries}<br />
    {/exp:channel:entries}

    I get a Parse error

    Parse error: syntax error, unexpected ‘?’ in /u0/webroot/virtual/nifootball2/admin/expressionengine/libraries/Functions.php(650) : eval()‘d code on line 18

  • #34 / Dec 03, 2010 6:37am

    James Smith

    259 posts

    Strange. I’ve tested this and it works ok for me, however I only tested using a hardcoded snippet. To narrow down the problem can you try hardcoding 1|113|577|2055| in the snippet to see if the error goes away?

    If it does then there might be a problem with Playa fields in snippets - I’d try going back to the embedded template approach and changing

    $list = explode("|","{exec_club}");

    to

    $list = explode("|","{embed:exec_club}");
  • #35 / Dec 03, 2010 6:46am

    Scott Boyde

    208 posts

    Strange. I’ve tested this and it works ok for me, however I only tested using a hardcoded snippet. To narrow down the problem can you try hardcoding 1|113|577|2055| in the snippet to see if the error goes away?

    If it does then there might be a problem with Playa fields in snippets - I’d try going back to the embedded template approach and changing

    $list = explode("|","{exec_club}");

    to

    $list = explode("|","{embed:exec_club}");

    The error goes away when you hardcode it.

  • #36 / Dec 03, 2010 8:12am

    James Smith

    259 posts

    Maybe try this - no snippet, just two templates (visit the first one in browser, not the second one):

    {exp:member:custom_profile_data}
        {exp:channel:entries channel="clubs" dynamic="no" entry_id="{exec_club}"}
            {embed="team_list" entry_ids="{club_teams}{entry_id}|{/club_teams}"}
        {/exp:channel:entries}
    {/exp:member:custom_profile_data}

    Embedded team_list template:

    {exp:channel:entries channel="teams" dynamic="no" entry_id="{embed:entry_ids}"}
        <h3>{title}</h3>
    <p>    {reverse_related_entries channel="fixtures" sort="desc" orderby="title"}<br />
            </p><h2>{title}</h2>
    <p>    {/reverse_related_entries}<br />
    {/exp:channel:entries}

    I’m slightly clutching at straws here, not sure if playa will work ok like that - if not I’d try the Tied Entries plugin, or at least ask Adam Khan whether he thinks it will solve this.

  • #37 / Dec 03, 2010 8:19am

    James Smith

    259 posts

    ... oh wait, that’s back to front isn’t it… will only return one club’s teams even if it does work. bah.

  • #38 / Dec 03, 2010 12:45pm

    Scott Boyde

    208 posts

    ... oh wait, that’s back to front isn’t it… will only return one club’s teams even if it does work. bah.

    Maybe that was what our problem was here as I do believe it now works. Just going to test a few different clubs just to make sure.

    :cheese:

  • #39 / Dec 03, 2010 12:50pm

    James Smith

    259 posts

    Oh ok, for some reason I thought you wanted a list of all clubs at once

  • #40 / Dec 03, 2010 12:52pm

    lebisol

    2234 posts

    Scott…are you set?

  • #41 / Dec 03, 2010 2:32pm

    Scott Boyde

    208 posts

    Oh ok, for some reason I thought you wanted a list of all clubs at once

    Apologies, but it was a list of all teams.

  • #42 / Dec 03, 2010 2:35pm

    Scott Boyde

    208 posts

    Scott…are you set?

    I am probably pushing my luck here, within the fixtures channel I have two fields, fixture_home_team and fixture_away_team.  These are relationship fields with the teams channel.

    Is it possible to display the team name.

  • #43 / Dec 03, 2010 2:41pm

    Scott Boyde

    208 posts

    Scrub that last one its not going to help anyway.

    I would like though but don’t think its possible to display a link depending on whether their team is the home or away.

    So if the team is Abbey Villa

    20-11-10 Downpatrick v Abbey Villa   Edit Away
    13-11-10 Abbey Villa v Dunmurry Rec   Edit Home

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

ExpressionEngine News!

#eecms, #events, #releases