Using tp.system.suggester variable later in a template

I’m trying to use a variable I’ve gotten from tp.system.suggester as part of a file move operation later on in my template.


But this throws an error (not sure what it says because I don’t know where to find the error console). Is there some way to refer to that tag/suggester variable in order for this move operation to work?

Looking more closely, I guess the tp.file.tags returns an array of string. I’ll have to figure out how to extract the first tag…

Well, back to the original “Can I use the suggester variable somewhere else”?

I have been trying to explore something similar today. Here is one way to do use the returned value

<%*

// Get the type of source 
const source_types = ["youtube","webpage","kindle"]
let input_source_type = await tp.system.suggester(source_types, source_types, true, "What is source type?");
let tags = "tags: [note/reference/" + input_source_type + "]"

_%>

Thanks, that helped with the file move, but now I’m not sure how the “tag” area gets populated…

I tried this:

<%* 
const departments = ["anim", "comp", "gen", "layout", "fx", "crdev" , "paint"]
let input_dept =  await tp.system.suggester(departments, departments, true, "What department do they work in?") 

let tags = "---\ntags: " + input_dept + "\n---"

await tp.file.move("STC/Crew/" + input_dept + "/" + tp.file.title) _%>

although that looks like it’s just setting the variable for tags and not actually including it anywhere, so then I tried:

---
tags: 
---
<%* 
const departments = ["anim", "comp", "gen", "layout", "fx", "crdev" , "paint"]
let input_dept =  await tp.system.suggester(departments, departments, true, "What department do they work in?") 

tp.frontmatter.tags = input_dept

await tp.file.move("STC/Crew/" + input_dept + "/" + tp.file.title) _%>

But that didn’t work either…

See the following for inspiration as to how to solve your issue:

2 Likes

Once again, thank you holroy! That is exactly what I was looking for!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.