Skip Navigation

[Resolved] Is it possible to realize such a relationship?

This support ticket is created 5 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 11 replies, has 2 voices.

Last updated by Serhii 5 years ago.

Assisted by: Waqar.

Author
Posts
#1379851

Hello, my new site is - hidden link (online gambling)

------ It has the next post type:

- online casinos (hidden link)
- providers (slots developers) (hidden link)
- online slots (hidden link)

One online casino can have connected many providers - hidden link

One provider can have connected many online slots - hidden link

------- I need to realize the next thing:

On the single page of an online casino will create View block with just those online slots whose provider has connected to the current casino.

-------- For example:

Online casino JoyCasino - hidden link
JoyCasino has connected the next providers: BluePring, BTG, Belatra, etc - hidden link
I need here - hidden link display slots providers who have connected to JoyCasino

Is it possible? Please help.

#1379911

Hi,

Thanks for asking and I'd be happy to help.

What you're planning is achievable using Toolset Types and Views plugins and this is how the structure will look like:

1. You'll need two post-relationships:

a). A one-to-many relationship between the "online casinos" post type and the "providers" post type.
b). A one-to-many relationship between the "providers" post type and the "online slots" post type.

You'll find the details on Toolset's post relationships at:
https://toolset.com/documentation/post-relationships/

2. To show the related providers and their related online slots, on a single online casino page, you'll need two post views:
( ref: https://toolset.com/documentation/getting-started-with-toolset/create-and-display-custom-lists-of-content/ )

a). The first and the parent view will be set to show those provider posts, which are related to the current online casino post.

b). A second post view will be nested in the parent view, which will show all the online slots posts, which are related to the current provider post, in the parent loop.

The following guides will help in better understanding how views can be used to show related posts and how can they be nested into one another.

https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/#adding-a-view-to-a-view

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1380937

I am sorry, but I do not understand what I am doing wrong.

I will describe what I have done:

For the best understanding, I took casino Riobet - hidden link
It has just one connected provider - BluePrint - hidden link
Provider BluePrint has 6 connected slots - hidden link (scroll down - hidden link )

So, I created two views:

a) relationship between the "online casinos" post type and the "providers" post type - hidden link

And this view works correct - hidden link

b) relationship between the "providers" post type and the "online slots" post type. - hidden link

Next, I nested b-view into a-view - hidden link and got this - hidden link

Please tell am I doing wrong?

#1381609

Hi,

Thank you for sharing those screenshots.

There are two things that need to be fixed.

1. The shortcode for the nested view ( [wpv-view name="b-view-nested-in-the-parent-view"] ) is outside the loop of the parent.

Screenshot: hidden link

To be properly nested, it should be inside the loop ( i.e. between the <wpv-loop> ... </wpv-loop> tags )

2. In the "Query Filter" section of the child view, the "The post where this View is shown" option is selected.

Since this child view is placed inside the loop of the parent view and is not used on a single slot page, "The current post in the loop" option should be selected.

Screenshot: hidden link

This should do the trick.

#1381895

Thanks, it helped and all works well now except one... except pagination.

Inside A-View I created pagination (6 items per page) - hidden link

But it does not work, on the page Riobet I do not see even pagination block hidden link (empty - hidden link)

I do not know why, but on the page Joycasino hidden link pagination is present but doesn't work (screen - hidden link)

Can you help me fix it?

#1381957

I updated WordPress to 5.3 version and got a lot of problems, so I restore the site from a backup and these two experimental View did not save.

I can recreate them if need or maybe do you understand what my problem is and recreating no need?

#1382217

Hi,

I've checked your website and the two new views are no longer available.

If you haven't added them back yet, you can create them again and let me know if you experience any issue with the pagination.

Once, the pagination is fixed, you can then update to the latest WordPress 5.3.

After that, in case you still come across any compatibility issue between Toolset plugins and WordPress 5.3, you're welcome to report that, through a new ticket and we'll have it investigated accordingly.

regards,
Waqar

#1382849

I created them again. The problem with pagination is actual

So what I have:

A - Parent View (casinos-providers) - hidden link
B - Child View (provider-slots) - hidden link

For example, the page where this view is displaying - hidden link (screen - hidden link)

In the settings of A - Parent View I have set in options 6 items per page - hidden link

After that, I can see pagination block on the front-end - hidden link but it works not correct, first - I see all 10 items on the first page (I should see 6), second - if I try to go on page two I get an empty page - hidden link

And one more thing I do not know why but on a similar casino page hidden link I even not see pagination block, but it should be - hidden link

#1383769

Hi,

Thanks for sharing the update.

Using pagination is complex in this case because the source of the slot machines posts is not a single view, but multiple views for each provider post.

To clarify, if you were simply showing the list of all slot machines, the list's structure from the view would look like this:

(1). Slot machine A
(2). Slot machine B
(3). Slot machine C
(4). Slot machine D
(5). Slot machine E
(6). Slot machine F

In that case, pagination would've worked to split the list into multiple pages.

However, in your usage case the structure is different:

1 - Provider A
-- (1). Slot machine A
-- (2). Slot machine B

2 - Provider B
-- (1). Slot machine C
-- (2). Slot machine D

3 - Provider C
-- (1). Slot machine E
-- (2). Slot machine F

Notice how the available slot machines are not at the same level and their ordering of results is changed and reset for every provider (the number in brackets).

If it's an absolute requirement to use pagination with this list of available slot machines, you'll need to adopt a slightly different strategy.

The two existing views ( "A - Parent View Casino - Provider" & "B - Child view Provider - Slot" ) will not be used to show the designed list of slot machines, but they'll be used only to get the IDs of all the applicable slot machine posts.
( in comma separated format e.g. 1, 2, 3, 4 .... )

You'll then create a new third post view for the slot machines posts, which will use those slot machine post IDs, to show those selected posts in the required design/layout. Since these posts would be coming from a single view, the pagination will also work.

Here are the steps:

1. "A - Parent View Casino - Provider" view:

- Please select "No pagination" in the pagination settings.

- To remove the extra content and spaces from this view's output, update the content in the "Loop Editor" section to:


[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-view name="b-child-view-provider-slot"]</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-layout-end]

- From the "Output Editor" section remove the shortcode [wpv-filter-meta-html] and check the option "Disable the wrapping DIV around the View" just above this section.

2. "B - Child view Provider - Slot" view:

- Remove the extra line breaks and spaces from the content in the "Loop Editor" section and replace content template shortcode with only post ID shortcode and a comma:
[wpv-post-id],


[wpv-layout-start][wpv-items-found]<!-- wpv-loop-start --><wpv-loop>[wpv-post-id],</wpv-loop><!-- wpv-loop-end -->[/wpv-items-found][wpv-layout-end]

- From the "Output Editor" section remove the shortcode [wpv-filter-meta-html] and make sure that the option "Disable the wrapping DIV around the View" is checked.

To test if these two views are working as expected use the shortcode of the parent view on any single casino page and see if returns the IDs of the relevant slot machines in the comma-separated format:


[wpv-view name="a-parent-view-casino-provider"]

3. "C - Actual view Provider - Slot" view (new):

- You'll create a new post view to show the slot machines post and in the "Query Filter" add a post ID filter to include only posts which are included through shortcode attribute:
( ref: https://toolset.com/documentation/user-guides/filtering-views-query-by-post-id/ )

Example screenshot: hidden link

- In this view, you can set the pagination settings and design the output according to the requirement, as the final output would be generated using this view.

To show this view on the single casino pages, you can place its shortcode like this:


[wpv-view name="slug-of-the-view" ids="[wpv-view name='a-parent-view-casino-provider']"]

Replace "slug-of-the-view" with the actual slug of your new view and note how the shortcode of the "a-parent-view-casino-provider" view is used in this shortcode to pass on the required post IDs.
( ref: https://toolset.com/documentation/user-guides/passing-arguments-to-views/ )

I hope this helps and please let me know if any step is not clear.

regards,
Waqar

#1383841

Thanks a lot for your instruction, I tried to do what you say, but it did not work. Can you check please what I did wrong?

#1384487

Hi,

I've checked the views on your website and here are my findings:

1. "C - View":

- The correct post type to show should be the slot machines and not the providers.
(this has been fixed)

Screenshot: hidden link

- The ids="[wpv-view name='a-parent-view-casino-provider']" part needed to be included in the shortcode that calls this view and not inside this view's "Loop Editor" section.

Screenshot: hidden link

The correct shortcode to load this view's content template is:


[wpv-post-body view_template="loop-item-in-c-view"]

(this has been fixed)

- The shortcode for this view is inside the element "Игровые автоматы связанные с Казино"
( hidden link )

This is where the ids="[wpv-view name='a-parent-view-casino-provider']" part needed to be included.


[wpv-view name="c-view" ids="[wpv-view name='a-parent-view-casino-provider']"]

(this has been fixed)

2. It seems that the GP element plugin that you're using to load this view "C - View" on the single casino pages, doesn't support the nested shortcode values.
( i.e. square brackets within the shortcode attribute )

For this reason, you'll need to include the above shortcode through a new custom shortcode that will work from this GP Element.

In your active theme's "funtions.php" file, you can include the following snippet that registers a custom shortcode that processes the same shortcode and returns the output:


function process_nested_shortcode_func( ) {

	ob_start();

	$post_ids = do_shortcode('[wpv-view name="a-parent-view-casino-provider"]');

	echo do_shortcode('[wpv-view name="c-view" ids="'.$post_ids.'"]');

	return ob_get_clean();
}
add_shortcode( 'process-nested-shortcode', 'process_nested_shortcode_func' );

Next, in your element "Игровые автоматы связанные с Казино", you can replace the shortcode [wpv-view name="c-view" ids="[wpv-view name='a-parent-view-casino-provider']"] with this newly registered custom shortcode:


[process-nested-shortcode]

regards,
Waqar

#1385161

Thank a lot Waqar, you really helped me! Now it is working as I expected