332 Posts
Kenneth
9 years ago
23
Topic
Hi, I'm trying to create this one to many relationship. I've got two content types, let's call them TYPE A and TYPE B. TYPE A content is the main articles. TYPE B is the sub articles. When creating TYPE B articles I want to select which TYPE A articles they should show on.

Then I created a related articles field in TYPE B which shows me TYPE A articles. I select one and save. I’ve also created a list & search type for TYPE B, where I load the related field and set it correctly according to Simons tutorial found here:

https://www.youtube.com/channel/UCKlMPUVqiJBo1R0pbn8k7Bw Then I add a module field to TYPE A and create a module. Just like in the tutorial and it works perfectly! So I’m ambitios and want to put the related articles field in TYPE B into a field x so that I can select more articles. Then it stops working. I can see that the place where the related articles field want to store it’s ID is not the same place as the field x wants to store the new multiple (or more) ID’s. I’ve tried changing storage settings with no luck. So now I’m stuck. Any ideas?
Get a Book for SEBLOD
572 Posts
_jrmo
9 years ago
5
Level 1

Hi Kenneth,

Firstly it's not Simon's tutorial, it's mine :) and my name is James.

I would not use the Article Related field. The tutorial was made a while ago and since then I've found that there is a better solution. I would advise you to use the Checkbox Dynamic field, although you can use the Select Dynamic field as well (they work the same way).

  • Step 1: Set up your Checkbox Dynamic field as in the attached picture. This will show you a list of your article titles (in the example I've got it showing all the articles from Category with ID 23), and will store their ID's in the database.

  • Step 2: Use the Checkbox Dynamic field in your search form, setting the "match" (button 3) to "Any words" and click the "+" and make the separator ","

 This approach will serve you better I think. Let me know how you go!

James

332 Posts
Kenneth
9 years ago
4
Level 2

First; I know that. I was 7++ hours deep into overtime when I wrote this.. :) Sorry about that.

Oh, what a sweet message to wake up to! Thank you! I will give it a go ASAP and check back.

332 Posts
Kenneth
9 years ago
3
Level 3

Hello again,

I can't get it to work. I've used a field x to repeat the dynamic select field, but the cell in the table where the ID's is supposed to store is just empty upon save. (At least where I think it should be stored, and I can't find it anywhere else I've checked either).

So, I'm thinking storage problem, but I'm not sure what that means settings vise. Ideas?

572 Posts
_jrmo
9 years ago
2
Level 4

Hi Kenneth. 

You don't need a Field X field at all. Your Checkbox field is going to get you a list of all the articles in your system, and then you just need to tick the applicable ones that you want to create the link to your content item.

No field x needed.

31 Posts
Catastrophix
9 years ago
1
Level 5

Hi James,

I really like the checkbox solution for related content, but am missing something fundamental.

Am I correct in the following logic:

  • Assign Dynamic Checkbox field to content type, confining to the category you're interested in relating through WHERE catid=xx
  • Selections will be stored in your SQL table for that content type delimited by commas (configured in the Dynamic Checkbox field)
  • Set up your list search type with CCK content type and the Dynamic Checkbox field as the search fields
  • Set live value on Dynamic Checkbox search field to 'variable' and add 'id' as the variable and set the type to INT

If my match settings are correct (Any Words Exact with comma specified as separator) I should be able to successfully filter the list? Somehow, no matter what I try (I have exhausted all matching options), I am unable to get the desired result - either all in my category or none.

Can you perhaps suggest an alternative method, or do you recommend I plug away at this? Do you know of any instance where the checkbox solution has worked? I also tried Kenneth's fieldx solution on the related articles field, but also wasn't able to identify where SEBLOD was storing the info (besides which, I still believe the checkbox solution is more elegant from a site admin UX perspective)

Should I perhaps look at the SQL Search plugin?

Thanks and cheers!

572 Posts
_jrmo
9 years ago
0
Level 6

Hi there,

Instead of 'INT', use 'int' >> I think it's case sensitive.

Also, what do you mean CCK content type? please send a screenshot of what the live value setting is on the CCK field in your search

Then of course embed your list on your page with a module or a search list field.

Let me know if that doesn't work.

Cheers,

James

332 Posts
Kenneth
9 years ago
7
Level 1

Ah, of course. Well, I've used Dynamic select field instead of dynamic checkbox field. And it works as well.

I'm just being picky now, but my goal was to have a dropdown to show the articles. Then select the relevant article. 80% of the cases it's just a 1:1 relationship.

The remaining 20% there will be need to add more, so I just wanted to use field x and repeat it when needed with a new dropdown.

Can that be done?

572 Posts
_jrmo
9 years ago
6
Level 2

Yes it can, I think.

If you use your original Article Related field, and a Field X, add the Article Related to your search form and set the match to "any words" then click the "+", set the separator to "," and from the "Collection" drop down select your Field X.

Does that work?

332 Posts
Kenneth
9 years ago
4
Level 3

Okay. I'm trying now. Just to clear things up:

The field being repeat with field x. how should that be? In the form? In content view? Hidden? Exluded from the views? :) Maybe this affects my result as well.

572 Posts
_jrmo
9 years ago
3
Level 4

Just include the Field X in your Site Form (or Admin Form) for now. 

The Article Related field should be in the Search Form with the settings I said above.

Your Item view or Content view fields don't impact your search results.

332 Posts
Kenneth
9 years ago
2
Level 5

I belive that this was my missing link: In the collection drop down, that I selected the field x.

But, I get this error: 

Table 'seblod_db.z3gu0_cck_store_join_introtext' doesn't exist SQL=DELETE a.* FROM z3gu0_cck_store_join_introtext AS a WHERE a.id = 11

This has to do with storage?

572 Posts
_jrmo
9 years ago
1
Level 6

This is why I wouldn't use the Article Related field. It has some complex behaviour which is useful for simple applications but gets confusing when you want to use it in other ways.

Instead of using a Field X you can use a Dynamic Select, with "multiple" set to "no". Then you will have your single <select> where you can chose your article, and use it within the Field X if you need multiple items.

332 Posts
Kenneth
9 years ago
0
Level 7

Nice. I'll try it with that. But, even with the error it seams to work. :P

Please message me your paypal, James, you are really a lifesaver!!

31 Posts
Catastrophix
9 years ago
0
Level 3

James, going through the screen grab exercise forced me to revisit my logic of how I was setting up fields in the 2 content types I was trying to relate/associate. I was being an idiot. The checkbox method for relating content in lists as you describe works like a charm.

Thanks!

332 Posts
Kenneth
9 years ago
8
Level 1

I got it to work with showing up, but it shows all - not just the ones that have picked the article. How do I get it to filter on the ID of the article in the field x in search & list type?

572 Posts
_jrmo
9 years ago
7
Level 2

Perhaps I told you the wrong "match" setting. Try also with "each word" instead of "any words" - double check as well that you have "," as the separator.

No need for any payment Kenneth, but thanks for your offer. I am part of the Octopoos team. You may consider to take out a VIP membership though if you want :)

_jrmo

332 Posts
Kenneth
9 years ago
6
Level 3

Oh, nice. :) I've got that planned. Just need to finish up some projects and I'll purchase a VIP to explore all the apps. :)

I've tried with different match types. But when I'm looking in the database, I can't find the ID's saved anywhere I would belive they should be saved? 

572 Posts
_jrmo
9 years ago
5
Level 4

If you've left the Field X storage as default, they will be store in the com_content table in the introtext column. There will be a heap of ::cck:: tags around the actual article ID values though.

332 Posts
Kenneth
9 years ago
4
Level 5

Field X is Custom->->Article->introtext. Should it be Default? (I've read it shouldn't).

Also, the select dynamic field is Default->Article->vis_under_dynamic (vis_under_dynamic is the name of the select dynamic field).

572 Posts
_jrmo
9 years ago
3
Level 6

You should make it at least introtext[vis_under_dynamic].

I can't really be of much more help from here. Field X storage is something I don't know THAT much about. 

An alternative solution you may consider instead of using Field X at all is to use the Select 2 jQuery plugin to transform your Select Dynamic (with multiple set to yes) in to a standard looking select field, with multi-selection capability... That may be another option.

https://select2.github.io/

332 Posts
Kenneth
9 years ago
2
Level 7

Well, the issue it seems is that when using either related article field or dynamic select field in the combination with field x, it dosn't get stored anywhere. I've tried using the fields default settings after adding them as well as trying to change the storage settings (hence, without fully understanding how these changes affect the results).

So... Maybe I'll have to look into Field X not storing.

572 Posts
_jrmo
9 years ago
1
Level 8

I know it's a pain but don't try to change the Field X storage once it's been saved - just create a new Field X with different storage and use that instead.

332 Posts
Kenneth
9 years ago
0
Level 9

Okey. Thanks a lot for trying to solve this with me!

I'll experiment some more and check back with a solution if I find one. 

Get a Book for SEBLOD