Page 1 of 1

Multiple Tags for Extra Columns

Posted: 10 Jul 2021 00:05
by Aeriessy
Hello again,
I wonder if it's possible to put a list of tags in an extra column and search them.
  • Example:
    Extra Column name: Ingredients
    File: Steak Sauce
    Data under Ingredients (ex1): Garlic, Butter
When I search "Garlic" it doesn't come up. I have to search "Garlic, Butter" for it to pop up. I understand the data is implemented as a string but I'm not sure the most efficient way to split it up. Is there a way to either:
1. Put "Garlic" and "Butter" into Tags and have a custom column that retrieves the Tags of a file and filter them out based on a list (if the Tag matches an entry on the list, it returns the tag. If not, it doesn't.
  • Example:
    List: Garlic, Butter, Ranch, Vinegar
    "Ingredients" Column for "Steak Sauce" would return "Garlic" and "Butter" since the Tags match entries in the list, but not "Ranch".

2. Have Extra Columns function like the Tags column (variables is a list separated by commas rather than one string).

Thoughts?

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 00:45
by jupe
Aeriessy wrote: ↑10 Jul 2021 00:05 When I search "Garlic" it doesn't come up. I have to search "Garlic, Butter" for it to pop up.
Wrap your search term in asterisks eg. *Garlic*

1) Yes it would be possible to script that.

2) No.

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 00:58
by Aeriessy
jupe wrote: ↑10 Jul 2021 00:45
Aeriessy wrote: ↑10 Jul 2021 00:05 When I search "Garlic" it doesn't come up. I have to search "Garlic, Butter" for it to pop up.
Wrap your search term in asterisks eg. *Garlic*

1) Yes it would be possible to script that.

2) No.
Do the asterisks indicate something? Like read a string like a list or something?

Might tinker with figuring out that script later. But YES, thank you. You've saved me disappointment from a disgusting amount of time researching. :lol:

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 01:11
by jupe
asterisks = wildcard

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 01:31
by Aeriessy
jupe wrote: ↑10 Jul 2021 01:11 asterisks = wildcard
Interesting, good to know what that means, haha. Thank you for all the information!

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 05:31
by Aeriessy
If anyone is lingering around, been trying to figure out a script for the first option I had listed. I'm not too great at it but I'm here so far, if anyone has any insight.

Code: Select all

$ingredientList = <<<>>>
Garlic,Butter,Ranch,Vinegar>>>;

$filetags = tagitems("tags", , <cc_item>);


foreach($variable1, $filetags, ",") {
   foreach($variable2, $ingredientList, ",") {
      if (compare ($variable1, $variable2)) == 0; {
         return $variable1}
      else {
         return "???";}
   }
}
So far it's showing up only the first variable if it matches with my ingredientList. I suspect my next steps are figuring out how to compare the items of two individual lists and return the matches in a different list variable. Still reading through all the content in how lists are compared.

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 07:04
by jupe
I am not 100% I know what you are trying to do, but here is a quick mock up of one way to do what it is I think you are trying to do, using regex would be faster if you are capable.

Code: Select all

  $ingredientList = "Garlic,Butter,Ranch,Vinegar";
  $return  =  "";
  foreach($tag, tagitems("tags", , <cc_item>), ",", "e") {
    if (gettokenindex(trim($tag), $ingredientList, ",")) { $return .= "$tag,"; } }
  return trim($return, ", ");
My understanding is that you want to tag with lots of ingredients but only return those that are in your $ingredientsList in this column.

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 08:24
by highend
Please do this with a regex as jupe suggested^^

Code: Select all

    $ingredientList = <<<>>>
Garlic,Butter,Ranch,Vinegar
>>>;
    return trim(regexmatches($ingredientList, "\b(?:" . replace(tagitems("tags", , <cc_item>), ", ", "|") . ")\b", ","), ",");

Re: Multiple Tags for Extra Columns

Posted: 10 Jul 2021 16:40
by Aeriessy
jupe wrote: ↑10 Jul 2021 07:04 I am not 100% I know what you are trying to do, but here is a quick mock up of one way to do what it is I think you are trying to do, using regex would be faster if you are capable.

Code: Select all

  $ingredientList = "Garlic,Butter,Ranch,Vinegar";
  $return  =  "";
  foreach($tag, tagitems("tags", , <cc_item>), ",", "e") {
    if (gettokenindex(trim($tag), $ingredientList, ",")) { $return .= "$tag,"; } }
  return trim($return, ", ");
My understanding is that you want to tag with lots of ingredients but only return those that are in your $ingredientsList in this column.
Ah, alright. I'll go into this direction, I'm understanding what you're leading to. Thanks for both of your inputs. <3