Dependent menu question

Dependent menu question

by Gemma Lesterhuis -
Number of replies: 9
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hello, 

I kind of hope someone can help me along with this. 
I used the instructions from William Lu's: Creating Dependent Menu with Database module

I have the menu's all set and in the View Single and Add entry it goes like predicted. 

Though I want my View List to do something similar. 

See enclosed Screenshot. 


In the first row (Praktijkopleiding Assurance) you can see that there is no button below "uitnodiging". 
And that is exactly what I want. 

Though I cannnot seem the script to work for the following rows sad

The button should only show when the text is "Open" in the same column. 



In the list template I have the following code. 
Which seems to work with the first row, but not with the next rows.



What I also want to try is that when the text is "open" that it not show the text field but only shows the button. 
But I think that everything I tried failed due to the same reason that the script does not seem to repeat on entry. 


if ('inschrijving' =="Open") {

       document.getElementById('Inschrijving').style.display='none';

}


Hope that someone can help me along. 

Gemma

Average of ratings: -
In reply to Gemma Lesterhuis

Re: Dependent menu question

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Gemma,

Could you please post a preset for the database for us to look at and work with?

In reply to AL Rachels

Re: Dependent menu question

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
In reply to Gemma Lesterhuis

Re: Dependent menu question

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Gemma,

I believe the problem is that every entry in your list view has the same id. I remember we had the same problem back when the Generico filter first came out and we tried to put more than one countdown clock on the same course page. Without a unique id for the filter to apply the changes too, every timer on the page showed the same output. Since your list has the same id for each entry,  only the first one gets matched, and gets "none" applied to it even when it is an "Open" entry, but with no URL.

Sorry, I have been working on other stuff and have not had a chance to work on it for other than a few minutes, and gotta quit for the day and do an errand for my wife.

In reply to AL Rachels

Re: Dependent menu question

by William Lu -
Picture of Particularly helpful Moodlers

Hi Gemma,

Yes, AL is right, 'id' is unique, hence can only be used once in a page.

So, we have to work around this, by not using the 'Button style'.

I modified your preset a little bit and the column looks like this now:


HTH



In reply to William Lu

Re: Dependent menu question

by Gemma Lesterhuis -
Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

William,

I see what you did - by forcing the URL to an automatic link. 

The issue with that is that I cannot turn it into a button. 

But if I understand you and Al correctly, there is no way around it?

Gem



In reply to Gemma Lesterhuis

Re: Dependent menu question

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

Hi Gemma,

There is a way around it. Just got to use something that should be unique as your id. SInce Moodle does not let us have an auto id field, we can use the next best thing, time created. Due to small time slice, you "shouldn't" get any duplicates.

NOTE:In my example picture, the first "Open" has no button because I left the URL empty.