Jump to content

Get Text Tags array from the text field to create checkbox filter


Ksenia
 Share

Recommended Posts

Hello all! I am pretty new to PW and now trying to figure out how to build a filter that uses AND logic and includes many fields. With help I have figured out Page Reference fields and Repeaters, but simple Text Filed with dropdown text tags makes me confused.

As I think of it, first I need to get the array of given fixed options of Text Tags here:

567479215_Screenshot2021-10-28at18_56_47.thumb.png.dca096ce795c1b42e718bf1567d554e0.png

And then I just need to print it out as checkbox form and circle through each page to see if they have the checked value in place of this field. 

Like what I have with page references:

1879794457_Screenshot2021-10-28at19_00_24.thumb.png.ce5de79794f47d32fbc1a1ad19eb46ae.png

But for the life of me I cannot figure out how to get this list...So if you have suggestions, I would really appreciate it!

Best,

Kseniia

  • Like 1
Link to comment
Share on other sites

This might be what you're looking for: 

https://processwire.com/api/ref/inputfield-text-tags/tags-array/ 

Corrected, this is the link:

https://processwire.com/api/ref/inputfield-text-tags/get-tags-list/

You can also get the inputfield from the field like this:

https://processwire.com/api/ref/field/get-inputfield/

Something like this might work, haven't tested: 

$inputfield = $page->getInputfield('tags_field');
$list = $inputfield->getTagsList(true);
foreach($list as $item){
   // echo checkboxes ?
}

 

Link to comment
Share on other sites

On 10/28/2021 at 7:31 PM, elabx said:

This might be what you're looking for: 

https://processwire.com/api/ref/inputfield-text-tags/tags-array/ 

Corrected, this is the link:

https://processwire.com/api/ref/inputfield-text-tags/get-tags-list/

You can also get the inputfield from the field like this:

https://processwire.com/api/ref/field/get-inputfield/

Something like this might work, haven't tested: 

$inputfield = $page->getInputfield('tags_field');
$list = $inputfield->getTagsList(true);
foreach($list as $item){
   // echo checkboxes ?
}

 

Thank you a lot! I adjusted it to my code and it works well!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...