Multiple Tags for Extra Columns

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Aeriessy
Posts: 7
Joined: 23 Apr 2020 14:37

Multiple Tags for Extra Columns

Post 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?
Just trying to figure it all out. :oops:

jupe
Posts: 2758
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Multiple Tags for Extra Columns

Post 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.

Aeriessy
Posts: 7
Joined: 23 Apr 2020 14:37

Re: Multiple Tags for Extra Columns

Post 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:
Just trying to figure it all out. :oops:

jupe
Posts: 2758
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Multiple Tags for Extra Columns

Post by jupe »

asterisks = wildcard

Aeriessy
Posts: 7
Joined: 23 Apr 2020 14:37

Re: Multiple Tags for Extra Columns

Post 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!
Just trying to figure it all out. :oops:

Aeriessy
Posts: 7
Joined: 23 Apr 2020 14:37

Re: Multiple Tags for Extra Columns

Post 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.
Just trying to figure it all out. :oops:

jupe
Posts: 2758
Joined: 20 Oct 2017 21:14
Location: Win10 22H2 120dpi

Re: Multiple Tags for Extra Columns

Post 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.

highend
Posts: 13275
Joined: 06 Feb 2011 00:33

Re: Multiple Tags for Extra Columns

Post 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", ","), ",");
One of my scripts helped you out? Please donate via Paypal

Aeriessy
Posts: 7
Joined: 23 Apr 2020 14:37

Re: Multiple Tags for Extra Columns

Post 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
Just trying to figure it all out. :oops:

Post Reply