michael-milette / moodle-filter_filtercodes

FilterCodes filter for Moodle enables content creators to easily customize and personalize course and site content using plain text tags (no HTML). For premium support, contact us at https://www.tngconsulting.ca/contact
https://moodle.org/plugins/filter_filtercodes
GNU General Public License v3.0
30 stars 42 forks source link

Feature Request: ifcourse_field_shortname contains #285

Closed jb-fol closed 6 months ago

jb-fol commented 6 months ago

Prerequisites

Feature Request - The User Story

As a user, I can see relevant content from custom course fields if the data exists.

Same functionality already exists for user profile fields with ifprofile_field_shortname

Screenshots / Mock-ups

No response

Alterative you have considered

No response

Additional information

No response

Planning on submitting a solution in a pull request (PR)?

No

Code of Conduct

michael-milette commented 6 months ago

Hi @jb-fol ,

The tags you may be looking for are:

{course_fields}: Displays the custom course fields.

{course_field_shortname} : Displays custom course field. Replace "shortname" with the short name of a custom course field all in lowercase.

NOTE: Respects a custom course field's Visible To setting.

If this is not what you need, please feel free to reopen this ticket.

Best regards,

Michael Milette

jb-fol commented 6 months ago

Thanks Michael - I’m successfully using course_field_shortname

What I was asking for was the same as in issue #84 which only shows the content if the profile field is populated.

michael-milette commented 6 months ago

Hi @jb-fol ,

Sorry for the misunderstanding. Please simply add a comment to #84 and you will be automatically notified when I make progress on that ticket.

Best regards,

Michael

acquaalta commented 2 months ago

Hi @michael-milette, Thanks again for your wonderful plugin and all the other contributions that you make to the Moodle community :-)

Let's say I want to display the following text in a label in a course:

Fruit: {course_field_fruit}

This is of course a "course_field_shortname" tag. And I know that if the relevant course field in that course is empty, nothing will be shown, and if it has content, it would be displayed. The thing is that in any case the preceding "Fruit: " text would be displayed to the user, and it would be strange since if there is not content to show, there would be a "Fruit: " text without something to follow it.

Is there any creative solution that you can think about, that would help us in this kind of scenario?

michael-milette commented 2 months ago

Hi @acquaalta ,

I've had to deal with that too. What I did in the past was to give the course field a default value like (not set yet), (to be completed) or (none).

Beyond that, we would need a new ifempty or something like that.

Best regards,

Michael