Database

Dependent menu question

 
Picture of Gemma Lesterhuis
Dependent menu question
Particularly helpful MoodlersPlugin developersTesters

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: -
Picture of AL Rachels
Re: Dependent menu question
Core developersParticularly helpful MoodlersPlugin developersTesters

Hi Gemma,

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

 
Average of ratings: -
Picture of Gemma Lesterhuis
Re: Dependent menu question
Particularly helpful MoodlersPlugin developersTesters

Hi Al, 


Of course.


Gemma

Picture of AL Rachels
Re: Dependent menu question
Core developersParticularly helpful MoodlersPlugin developersTesters

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.

 
Average of ratings: -
Picture of William Lu
Re: Dependent menu question
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



 
Average of ratings: -
Picture of Gemma Lesterhuis
Re: Dependent menu question
Particularly helpful MoodlersPlugin developersTesters

Thank you Al and William for taking a look. 



 
Average of ratings: -
Picture of Gemma Lesterhuis
Re: Dependent menu question
Particularly helpful MoodlersPlugin developersTesters

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



 
Average of ratings: -
Picture of AL Rachels
Re: Dependent menu question
Core developersParticularly helpful MoodlersPlugin developersTesters

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.


Picture of Gemma Lesterhuis
Re: Dependent menu question
Particularly helpful MoodlersPlugin developersTesters

Oh that is great. Thank you Al. 
I will try this out tomorrow. smile 

 
Average of ratings: -
Picture of William Lu
Re: Dependent menu question
Particularly helpful Moodlers

We can use CSS to make it looks like a button, not as beautiful as the default button, but you can add your own style.


 
Average of ratings: -