Help get this topic noticed by sharing it on Twitter Twitter, Facebook Facebook, or email.
Scott Boyde

Update Playa field in one channel when a new entry is created in another

Not sure if this is possible or if I am going about htis the right way. I currently have a channel called Fixtures, I create all the entries within this channel but allow members to add a report into one of the fields.

When displaying this report field on the site I am always the author and I would like to have the member that added the report as author. So the only way I know is to move this field into its own channel.

I would like then to link the report to the Fixture and was thinking of doing so with playa, I have created a playa field called report in Fixture Channel. I have also created a Channel called Reports.

I would like to update the report playa field in Fixture Channel with the entry created in the Reports Channe. Can this be done.
1 person has
this question
+1
Reply

  • Hi Scott,

    Was the Report field a Matrix field? Matrix doesn't keep track of who created each row. The only thing I could think of there would be to add an Author column, where they’d have to manually select themselves.

    But moving reports into their own channel is probably a wise decision.

    Playa itself wouldn't be able to auto-update a field to select new entries as they're created. You could write an extension that does it, but I don't see the point. If reports are getting selected automatically, why not just loop through the Reports channel directly in the template? What's the point of linking them to the Fixture channel in the first place?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Scott Boyde
    Originally the report field is a wygwam field.

    The data on the site is for Football/Soccer, and the Fixture channel entries hold all the information about a particular fixture/match.

    Home Team
    Away Team
    Goals
    Match Report

    The report is a few paragraphs about what went on during the match so it will need to be associated with that particular entry.

    I'm still learning my way round EE and its very slow going at the moment so I am not sure what the best way to do this will be.

    It was only when I was trying to display the latest reports on the homepage that I seen that all the authors where me. I was also looking to display The lastest News and Reports on the homepage but found this difficult as they use separate field groups.

    But as the News Channel only has a body field (wygwam) and Photo (matrix) and the Report is only a body field (wygwam) then I could use that channel.

    But its the same trying to link the report to the fixture its about.

    I maybe could add the relationship to the Report Channel and when the user is viewing their fixtures they click a link with the fixture id and update the relationship with that. Can you update a playa field with a segment value.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • This reply was removed on 2011-12-22.
    see the change log
  • I think putting the Playa field on the Reports channel, so each report chooses a fixture, rather than a fixture choosing all the reports, is the right choice.

    Not sure what you mean by, “Can you update a playa field with a segment value.”
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Scott Boyde
    Would it be better to have the News and Reports in the same channel.

    “Can you update a playa field with a segment value.”
    Sorry that was badly worded.

    When users go to add the reports they have a list of the fixtures for their team. There is a link that opens an SAEF for them to add the report. At the moment this just gets added to the Fixture entry. But if I changed it to create a new entry in Reports Channel (Or News) then I need to link that with the original fixture. Am I wrong in saying that the playa field holds the entry_id of the related entry.

    If it does I was thinking that in the SAEF I could have then entry_id of the fixture in the url and then set the url segment to update the playa field.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Sure. You'd just need to put this in your SAEF:

    <input type="hidden" name="fixture_playa_field[selections][]" value="{segment_X}" />


    That’s all Playa needs to know that it should link up the entry with the ID in {segment_X}.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Scott Boyde
    Hi Brandon been a while since I have been able to look at this, but that works grand.

    I'm a bit unsure about the tags I need to use when pulling the fields from the plays field in the templates.

    My reports template pulls in the relevant fields from the reports channel and we have the playa field that relates to an entry in the fixtures channel.

    The fixtures channel has some of these fields.

    fixture_home_team relationship
    fixture_away_team relationship
    fixture_home_team_goals text
    fixture_away_team_goals text

    Could you help me with the tags needed to display these, thanks.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Hi Scott,

    If you want to show a Playa field in your SAEF, you can get to it with {field:field_name}.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Scott Boyde
    Sorry Brandon probably should have started a new one, this is for displaying the new entry and playa data.

    Made a bit of a foopar and named the palay field the same as the other channel, once I got that I have been able to get the following working.

    {exp:channel:entries disable="member_data|pagination" channel="reports" dynamic="yes" limit="1"}

    {exp:playa:children field="photo"}

    {exp:channel_images:images url_title="{url_title}" cover_only="yes"}
    {image:title}
    {/exp:channel_images:images}
    {/exp:playa:children}

    {body}

    {exp:playa:children field="photo"}
    MATCH PHOTOS: {title}
    {/exp:playa:children}

    {/exp:channel:entries}

    But what I can't get is two relationship fields from the playa field

    fixture_home_team relationship
    fixture_away_team relationship
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Scott Boyde
    Hi Brandon, any ideas what I am doing wrong to display the standard relationship from from a playa child field.

    Thanks
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Sorry, I’m a little confused. But it seems like maybe what you’re trying to get after is Nested Relationships?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • Scott Boyde
    Brandon

    Apologies for the confusion, I think that the nested is what I need but can you use that for a normal EE relationship field rather than another playa field I did try that and didn't work, though its probably my code.

    I was going to post what I have, but for some reason my control panel is very slow to unusable really nit sure whats going on there. WIll get back soon.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly

  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned happy, confident, thankful, excited kidding, amused, unsure, silly