Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I have a template where i (or registered users from the frontend) store products that are sold in the website. Each product can have any number of tags that allows users to filter/search by that. This is a relation field in the products template, declared like so:

Code: Select all
<cms:editable 
        type="relation" masterpage="tag/index.php"
        name="tags" label="Tags list" orderby="page_title" order_dir="asc" />


Until today, I was showing the normal checkbox list using an input with type "bound" on the product add/edit form and it was working fine. But as the number of tags increases, I decided to do a nice upgrade and give users the option to specify the tags themselves using an input that also suggests tags that already exist.

Image

Now I'm struggling with saving the tags that were inputed by the user. The tags that the user entered in the input must replace the current ones.
Right now I only have this piece of code that checks if the tag already exists, but I feel like it's the wrong approach:

Code: Select all
<cms:each frm_tags sep="," >
    <cms:set cleanTag = "<cms:php>
          echo str_replace(' ', '-', strtolower('<cms:show item />'));
    </cms:php>" />
    <cms:set tagExists = "<cms:page_exists cleanTag masterpage='tag/index.php' />" />
</cms:each>


So what's the actual value of the relation field? Is it a set of IDs of each page in the Tags template? Or is it possible to achieve this by assigning the "tags" relation field simply an array of every cleanTag provided by the user?

Thanks,
Olsi
Hi Olsi,

As a drop-in replacement for the old checkbox list (which does get unwieldy as the items grow), we released an advanced GUI for relations a while back -
viewtopic.php?f=5&t=11021

I wonder if that wouldn't be the easier solution in your case?
Please let me know.
Hi KK,

Thanks for your reply.
Yes I've seen the new advanced relation field manager and it surely would be easier to implement. But I'd prefer to keep this approach as I think it's more practical for a user to quickly type their desired tags. And when submitting the form, the tags relation field of the newly created (or edited) product will have those values. Would it be possible to implement something like that?
It should certainly be possible given the required effort to create something from scratch.
We don't have anything like it ready for you to use at this moment, I am sorry.
Alright, I'll see if i can come up with something.

Thanks KK.
5 posts Page 1 of 1