Functions to show or hide info

Use case or problem

What I’m suggesting is having functions that, given certain requirements, display specific information on the screen, and if those requirements aren’t met, keep it hidden. Something like what we already have in database filters, but for information within each note. Perhaps this is a very specific idea for - , but I still think it’s a good one.
A hypothetical example could be:
I’m trying to put together a career plan, and I thought it might be a good idea to have a way of organizing myself, so that when I complete a subject, the next one is automatically displayed, but not there until I’ve marked it.

Proposed solution

Going back to the example, I check one box for calculus and another for linear algebra. If those boxes aren’t checked, then nothing is displayed. But if I check one, then other boxes are displayed. For example, if nothing is ckecked, nothing shows up (1), if I check calculus, physics 1 is shown (2); if I check the other box, physics 2 is shown (3); if I check both, physics 3 is shown (4); and if I check both calculus and physics 1, chemistry is shown (5). This way, I have many chained statements. A kind of chained IF statement.

1-image

2-image

3-image

4-

5-

Current workaround (optional)

Related feature requests (optional)

You can already make custom dataviewjs-scripts that achieve this or something comparable.

I think this might be exactly what you are looking for :slight_smile:
The tasks-Plugin is a great plugin and has a well written documentation. For you the blocked property will be relevant. Also, to improve the example later, check out the documentation for queries there.

The following is a very basic example, that does not take into account “branching decision trees”, but just an ordered list.

First you have to have a .md-File containing the tasks in the order you want to work on them. Although you can have them anywhere in your vault.

In the same or a different file you enter the following ```dataviewjs-block:

let calloutType ='abstract'; 
let boxTitle = 'Recurring';

const query = `
(path includes 01_Inbox/Careerplan.md)
not done
limit 2
`;

function callout(type,title,text) {
    const allText = `> [!${type}] ${title}\n` + text;
    const lines = allText.split('\n');
    return lines.join('\n> ') + '\n'
}
dv.paragraph(callout(calloutType, boxTitle,'```tasks\n' + query + '\n```'));

Change 01_Inbox/Careerplan.md to whatever the the file location and name is.

The code returns you the following:

If tasks are checked, the callout-box gets updated. It doesn’t matter if you check them in the original file or in the callout box. They get changed in the original file. You can move the code wherever you want. I had these blocks in my daily notes and they looked in the whole vault for open tasks.

This is how the callout-box changes, when the boxes are checked.

Properties:

calloutType: color of the box
boxTitle: What is shown on top of the callout. Instead of “Recurring” you could do “Careerplan”
limit 2: shows 2 entries. higher number, more checkboxes displayed
(path includes 01_Inbox/Careerplan.md): location of the file with the Task-list. You can logically multiple files join multiple files to look at with AND or OR

You can edit the query however you like.

the function and the dv.paragrath do not need any editing

If you need some help with the task-plugin or queries, let me know :slight_smile: