Welcome, Guest
Username: Password: Remember me

TOPIC: Filter result of the List FROM ForeingKey

Filter result of the List FROM ForeingKey 27 Dec 2013 19:40 #11855

  • neoneper
  • neoneper's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 2
  • Karma: 0
I am desperately trying filter the results in a list that was generated through a ForeingKey.

I configured the Foreing to show a list of results by Name. Until then that's OK because this is standard in Online generator.
My real problem is that I need condition the results obtained by foreIngKey to show only the results that have the USER ID equal to the user who created it.

How can I add more condition to the results of this foreingKey List?

PS: The requirement applies on the "form" of the create new Item and Item. Everything is being done to FrontEnd
IMAGE 1


In the picture below (Image 1), is possible to see the system working.
[Escola Bom Jesus] is a chosen value when I created this entry. This value is obtained starting from a Foreign Key.



In this second image, it is possible observe the LIST I spoke at my question.
I received 2 Values by Foreign Key.

1 -> Emiliano Perneta
2 -> Escola Bom Jesus

My question is as follows:
Emiliano Perneta, is an entry that not created by the current user.
The Only it was actually created by current User is the (School Bom Jesus), so I need Hide the value of choice (Emiliano Perneta).
Only "Escola Bom Jesus" should be shown in the list because this is the one created by the current User...


Please. Could someone give me a hint.
Which file do I modify to meet my need? I already looked all that I know and I can not find any file that contains snippets of familiar script for me to modify.
The administrator has disabled public write access.

Filter result of the List FROM ForeingKey 27 Dec 2013 22:14 #11857

  • neoneper
  • neoneper's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 2
  • Karma: 0
OOOOYA!
After trying several different ways i done one that meet my need!.

My list of items was being generated in the form, from this line:

At: com_mycomponent/views/myItems/view.html.php
...
protected function displayNewmyItems($tpl = null)
{
...
$lists['fk']['institute'] = $model_institute->getItems(); 

So what I did was the following:
1) I copied this array to another array (temporary ).
2) I removed of the list all values ​​that were not created by the current user
3) Added this modified array in the list again!. END.
               //GET USER ID 
		$userId		= $user->get('id');
		
		//GET ITENS LIST FOR TEMP ARRAY
		$Newlists = array();		
		$Newlists = $model_institute->getItems();
		
		//ARRAY FOR MODFY
		$setNewList = array();		
		$count = 0;
		foreach ($Newlists as &$obj) 
		{
			if($obj->created_by == $userId)
			{    			
				$setNewList[$count] = $obj;
				$count ++;
			}
		}
		
		$lists['fk']['institute'] = $setNewList; //OYA ITS WORK

Now showing only the items that the own user has created. This is great...

But I have another problem.

At: com_mycomponent/_fork/views/myItems/view.html.php

I'm trying to add this modification to _fork to keep me whenever you make an update.
I'm adding in their place, but this not succeeding. He continues to show the file outside of fork.
I already read the tutorial in the Documentation. This is apparently simple, do not know why does not work!
Last Edit: 27 Dec 2013 22:20 by neoneper.
The administrator has disabled public write access.

Filter result of the List FROM ForeingKey 27 Dec 2013 22:28 #11858

  • neoneper
  • neoneper's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 2
  • Karma: 0
well-done (X.x)!
Problem solved about fork.
You must rename the folder (_fork) to (fork) without underline. (T.T).
Please include this observation in Moderator documentation.!
The administrator has disabled public write access.
The following user(s) said Thank You: jcombuilder

Filter result of the List FROM ForeingKey 30 Dec 2013 11:03 #11868

  • jcombuilder
  • jcombuilder's Avatar
  • Offline
  • Junior Member
  • Posts: 21
  • Thank you received: 4
  • Karma: 1
Hello neoneper,

The list is very quiet I see over the Holidays. I just wanted to say a BIG thank you for your answers which have assisted me a great deal.
Well Done.

Edward.

JComBuilder.
I'mmm Back!
The administrator has disabled public write access.

Filter result of the List FROM ForeingKey 30 Dec 2013 17:02 #11872

  • neoneper
  • neoneper's Avatar
  • Offline
  • Junior Member
  • Posts: 35
  • Thank you received: 2
  • Karma: 0
TANKS Brother (^.~) HappyNew Year for ALL! (^.~).
The administrator has disabled public write access.
Time to create page: 0.081 seconds

Get Started