Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to work with an array? #2

Open
radoslavius opened this issue Aug 11, 2016 · 9 comments
Open

How to work with an array? #2

radoslavius opened this issue Aug 11, 2016 · 9 comments

Comments

@radoslavius
Copy link

Hi,

your library is amazing :)

In the latest version of Pace is field tags. How can I to search by this field and how to enter this field?

Thanks
Radek

@radoslavius
Copy link
Author

radoslavius commented Aug 11, 2016

Partial response after testing for searching is: ...->filter('@tags', '{5003}')->find();

@radoslavius
Copy link
Author

And here is the rest of the response, including examples of how to complete the model for working with tags:

    public function getTags()
    {
        $tags = $this->getProperty('tags');
        if (isset($tags)) {
            return json_decode($tags, true);
        }
        return null;
    }

    public function addTag($tag)
    {
        $tags = $this->getTags();
        if (!isset($tags)) {
            $tags = [];
        }
        $tags[] = $tag;
        $this->setProperty('tags', json_encode($tags));
    }

    public function removeTag($tag)
    {
        $tags = $this->getTags();
        if (isset($tags)) {
            if (($key = array_search($tag, $tags)) !== false) {
                unset($tags[$key]);
            }
            if (count($tags)) {
                $this->setProperty('tags', json_encode($tags));
            } else {
                $this->setProperty('tags', '');
            }
        }
    }

@robgridley
Copy link
Owner

Is this part of the custom forms and fields module?

@radoslavius
Copy link
Author

You mean field tags? This is a new functionality of pace.
image

@radoslavius
Copy link
Author

image

@robgridley
Copy link
Owner

Is that new in v28? We're running v27.

@radoslavius
Copy link
Author

Yes, we are running on v28.

@robgridley
Copy link
Owner

I've opened a support ticket with EFI to upgrade our staging server to v28. Once I can test, I'll merge and release a new version.

@robgridley
Copy link
Owner

Vicki Atkins is working with me on the upgrade. I asked if I can get access to a v29 server to speed up the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants