Possible to comma separate words in fields and make them individually 'linkable'?

Hi all!

I have built a fairly basic site for an academic research group, including a collection of projects, a team page, a calendar, blog etc. The Projects page is constructed with dynamic pages (organised by boolean fields as Categories) and items (organised by a Project Number field). In the connected dataset, contributors are listed in a single Author(s) field as ‘John Doe, Jane Doe’ etc, and this information is in turn displayed on each related item page as simple text.

For some extra flair, I would love it if the Team page (constructed with a repeater, linked to a separate dataset) could somehow allow for the visitor to click a name and come to a dynamic page collecting all projects this person is involved with. Another cool thing would be to be able to make the names on the item pages clickable, meaning you can jump back and forth between project item pages and Team page.

This would be an easy enough task if there was only one contributor listed in the Author(s) field for each item of the first dataset, but since this is rarely the case I wonder if there is a clever way to accomplish what I just described? I would like to avoid a hundred boolean fields if possible.
Let me know if my description is unclear and I’ll try to do better :slight_smile:

Thank you so much!!

Hello Helena

you can allow the visitor to click on the name to show all the projects the person is involved with as follows:

  • add a reference filed in both collections. and make sure it is set to multiple items .

  • create a dynamic page connected to the teams database

  • on teams page, add onClick event for the text box.

  • when the text box is clicked, get the current item from the repeater using $w(‘#dataset’).getCurrentItem()

  • use wixLocation.to() to redirect the visitor to the teams dynamic page

  • in the dynamic page, you can add a repeater to show the projects

  • to show only projects for this name, add a filter to the reference flied in the projects data set based on the full name. $w(“#dataset”).setFilter( wixData.filter() .contains(“team”, “full name”). not that you can get the full name from the dynamic data set.
    here’s some useful articles:

  • reference fields

  • onClick event

  • getCurrentItem()

  • wixLocation.to()

  • setFilter()
    Best!
    Massa

Dear Massa,

Thank you!
Just a few questions - when adding reference fields in both collections, how am I supposed to link them? They never appear in any drop-downs. Also, I don’t understand how to set them to ‘multiple items’.
Appreciate it!

Hello Helena

you can link them by choosing what referenced collection you want to link to:

here’s you can set it to multiple items:

Massa

Dear Massa,
Thank you. However, I don’t seem to have the option to select multiple items…? I don’t get the bottom button in the Manage Field pop up.

Hello Helena
go to ‘Team’ collection -->’ Projects by Author’ field → manage field → manage properties → scroll down you’ll find ‘Multiple items’ and fill the projects. then go to BCTArchieve find the ‘team’ field you’ll find for each project what team member has it.

Massa

Hi Helena:

Massa is showing you wherein the data collection you need to configure the reference that you need to set up to ‘join’ two data collections. Once this is done you obviously need to make sure that you are able to add the reference links in the table to establish the relationships between teams, team members, projects. So it is important that you understand the data models you are using and the relationships each collection has to the others.

As an example you may want to consider three Data collections TeamMember, Team and Project
It sounds like Team and TeamMembers is a ManyToMany relationship:
Team hasMany TeamMembers
TeamMember hasMany Teams
So you would add a reference field in Team that allows for multiple TeamMember references
and you would add a reference in TeamMember for multiple Team references

It sounds like Team and Project could be a ManyToOne relationship? 
       Project belongsTo Team 
       Team hasMany Projects 
So you would add a reference field in Project that can contain only one Team 
and you would add a reference field in Team that can contain multiple Projects. 

Then you would use dataset filters connecting the relevant tables to get the results you are looking for.

Now - in your original question you mentioned that you have a text list of team members in the project. The TeamMember collection I mention above would potentially replace this text field.

You could still do something similar with this text field, but you may find it a lot of code.

You would need to extract each member from the list using a string split function to create an array of team members . With this array you could populate a repeater with a button or text element that is clickable and named using the team member name.

When the repeater button is clicked you would then need to find each project that contains the button element name in the project team member list of other projects. You can use the same string split method and then search the resulting array or you can use the string includes function to see if the team member’s name is present. This will help you build an array of matching projects for the Team Member.

WARNING: The reason why using a data collection for TeamMembers is probably more preferable to a text list comma separated is because text can be problematic. If you are letting project managers or team leads enter team member names in free form then you will have to start thinking about the multiple ways names could be entered. For example there may be a team member called Samuel Smith. This name could appear in multiple different ways:

  • Samuel Smith
  • samuel smith
  • Sam Smith
  • sam smith
  • S Smith
  • s smith
  • Smith

You may also have name conflicts (there may be two Sam Smiths).

So when you are building the list of projects that Sam Smith is on you will need to make sure you cater for all the variations and duplicates.

The way to prevent this is to have unique records for each team member and use drop down lists to add them to the project or force naming and spelling conventions on the text entry :-).

In addition to Massa’s reference recommendations you might want to check out these articles:

https://support.wix.com/en/wix-code/connecting-data

Hope this helps
Steve

Massa,
I’m sorry to bother you with these trivial things, but I just don’t get the Multiple Items button… Scrolling not possible either.

Hello Helena

I checked your editor and collections and i can find it from my end, i’ll set it to you now.
i suggest you contact the support team for this issue.

Massa

1 Like