We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

how can get only member channel entry on channell relations?

How Do I?

Andrés Molina's avatar
Andrés Molina
43 posts
5 years ago
Andrés Molina's avatar Andrés Molina

im have field type “RelationShip” For example have Channel “Birds” And Channel “OwnBirds” Im need show Only Member Birds on “ownbirds” Channel, now can see other members birds.

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
5 years ago
Robin Sowell's avatar Robin Sowell

Ah, so in the relationship field, you want to be able to limit the options they can select to only those entries authored by the person making the current entry?

It’s not possible to do that natively. We’ve talked about it a bit and there are some concerns about what happens if someone else edits the entry- what happens then. But it is an interesting feature idea.

For now, you’d need to write a custom extension to get that sort of behavior though.

       
Andrés Molina's avatar
Andrés Molina
43 posts
5 years ago
Andrés Molina's avatar Andrés Molina

yes, im write a custom function

like this

public function getCanal(){
  $this->channel_id = (ee()->TMPL->fetch_param('channel_id'))?ee()->TMPL->fetch_param('channel_id'):0;
  $entradas=array();
  $entries = ee('Model')->get('ChannelEntry')
      ->filter('author_id', ee()->session->userdata('member_id'))
      ->filter('channel_id',$this->channel_id ) // or whatever you want/need to filter on
      ->order('title', 'ASC');
  foreach($entries->all() as $ent){
   $entradas[]=array(
      "chan_title"=>$ent->title,
      "chan_url_title"=>$ent->url_title,
      "chan_entry_id"=>$ent->entry_id,
   );
  }
  
  return ee()->TMPL->parse_variables(ee()->TMPL->tagdata, $entradas);
 
 }

and call from template to draw select box with only logged member entries in specific channel

{exp:tcdcl_utilities:getCanal channel_id="11"}
{chan_title}
{chan_url_title}
{chan_entry_id}
{/exp:tcdcl_utilities:getCanal}
       
Robin Sowell's avatar
Robin Sowell
13,158 posts
5 years ago
Robin Sowell's avatar Robin Sowell

Hrm- I was thinking an extension, using hook:

‘relationships_display_field’ hook. // - Allow developers to perform their own queries to modify which entries are retrieved

https://docs.expressionengine.com/latest/development/extension-hooks/api/channel-fields.html#custom_field_modify_dataee_fieldtype-ft-method-data

That would work in the cp too.

I’m pretty sure that’s how I’d go, but your logic looks sound as well.

       
Andrés Molina's avatar
Andrés Molina
43 posts
5 years ago
Andrés Molina's avatar Andrés Molina

thanks, im need learn how can use a hook, you have an Real Worlds example?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.