Related data with conditions in the list view

zucchetti

Member
Hi!

I have a list, with forms added through related data, so that in the list view I have added buttons to four more forms. With help from the forum, I?ve managed to modify the list template to add a condition to show or not show the other buttons depending on how a yes/no element is set. That element belongs to the main form/list.

Now, I need the buttons to be shown depending on element values of previous forms. I ask people to complete the "main" form, then, if a cetrain element is set to a certain value, I want to show the next button (of the second form), then, if a cetrain element of the second form is set to a certain value, I want to show the button of the third form, then if a certain elemnt of the third form is set a certain value, I wan to show the buttons related to the fourth and fifth forms.

I hope I?ve made my point.

Thanks in advance.

PS: It?s the list id 55 from my registered site.
 
You'll have to figure out the query to do that.

How are the forms related? So if you are displaying form2, how do you know which row in form1 to check?

As an example, I'll assume they are related by a user element, so you want to find a value from form1, when rendering form2 ...

Code:
$myUserId = JFactory::getUser()->get('id');
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('somefield')->from('form1')->where('user_id = ' . $myDb->quote($myUserId));
$myDb->setQuery($myQuery);
$somevalue = $myDb->loadResult();

You can then use $somevalue to decide whether to show the link or not.

If it isn't user ID, you'll need to explain how the rows are related across tables. Like, for instance if you have a table1_id on table2, that points to the rowid in table 1 associated with this table2 row.

-- hugh
 
Thanks for your answer.

The relation between the forms is not exactly by user.
I have made databasejoin elements in forms 2, 3 , 4 and 5 that take information from an element in form 1.
 
So forms 2, 3, 4 and 5 are related to form 1? So you have joins on those that point to the 'id' (primary key) of form 1?

The more information you give me, the better I can help.
 
Exactly, I ask people to complete an element in form 1, and then I?ve made databasejoins to keep using that information in the rest of the forms. In all my databasejoins I use the table that saves form 1, the value id (recommended) and the tag id.

The thing is that I don?t know if it is possible to make conditions in the list template regarding elements that don?t belong to the "main form(1)"
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top