Hi Mike,
Thank you for waiting.
Based on my tests, for what you are planning, it would be best to create a form with the dropdown for the Seasons and Episodes section using two post views. These will be the steps:
Step 1: "View to show Seasons":
- You'll create a post view, and set it to show "Seasons" posts.
- In the "Query Filter" section, you'll add a post-relationship filter for the "TV Series -> Seasons", linked to "The post where this View is shown"
( screenshot: hidden link )
This filter will ensure that only seasons related to the current TV series are returned by this view.
- In the "Loop Editor" section, you'll need to construct the view's output in a way that it includes a form with the seasons and episodes select/dropdown fields.
[wpv-layout-start]
[wpv-items-found]
<form action="" method="GET">
<div class="form-group">
<label for="wpv-season">Seasons</label>
<select name="wpv-season" class="season-select">
<option value="">-select-</option>
<!-- wpv-loop-start -->
<wpv-loop>
<option value="[wpv-post-id]" [wpv-conditional if="( '[wpv-search-term param="wpv-season"]' eq '[wpv-post-id]' )"]selected="selected"[/wpv-conditional]>[wpv-post-title]</option>
</wpv-loop>
<!-- wpv-loop-end -->
</select>
</div>
[wpv-conditional if="( '[wpv-search-term param="wpv-season"]' ne '' )"]
<strong>Season Description:</strong><br>
[wpv-post-body view_template='None' item='[wpv-search-term param="wpv-season"]']
[/wpv-conditional]
<hr>
[wpv-view name="view-to-show-episodes"]
</form>
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
Note: You'll replace "view-to-show-episodes" with the actual slug of the view that will be created in the next step.
- In the "JS editor" tab under this "Loop Editor" section, you'll need to include some custom script, that will reset the episode selector/dropdown and submit the form when season selector/dropdown is changed:
jQuery('select.season-select').on('change', function() {
jQuery('select.episode-select').val('');
this.form.submit();
});
- Please also make sure that "Disable the wrapping DIV around the View" option is also checked just above the "Output Editor" section.
Step 2: "View to show Episodes":
- You'll create another post view, and set it to show "Episodes" posts.
- In the "Query Filter" section, you'll add a post-relationship filter for the "Seasons -> Episodes", linked to the URL parameter "wpv-season".
( screenshot: hidden link )
This filter will ensure that only episodes related to the Season post whose ID exists in the URL parameter "wpv-season" are returned.
- In the "Loop Editor" section, you'll need to construct the view's output in a way that it includes a select/dropdown field for the available episodes:
[wpv-layout-start]
[wpv-items-found]
<div class="form-group">
<label for="wpv-episode">Episodes</label>
<select name="wpv-episode" class="episode-select">
<option value="">-select-</option>
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-conditional if="( '[wpv-search-term param="wpv-season"]' ne '' )"]
<option value="[wpv-post-id]" [wpv-conditional if="( '[wpv-search-term param="wpv-episode"]' eq '[wpv-post-id]' )"]selected="selected"[/wpv-conditional]>[wpv-post-title]</option>
[/wpv-conditional]
</wpv-loop>
<!-- wpv-loop-end -->
</select>
</div>
[wpv-conditional if="( '[wpv-search-term param="wpv-episode"]' ne '' )"]
<strong>Episode Description:</strong><br>
[wpv-post-body view_template='None' item='[wpv-search-term param="wpv-episode"]']
[/wpv-conditional]
<hr>
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
- In the "JS editor" tab under this "Loop Editor" section, you'll need to include some custom script, that will submit the form when episode selector/dropdown is changed:
jQuery('select.episode-select').on('change', function() {
this.form.submit();
});
- Please also make sure that "Disable the wrapping DIV around the View" option is also checked just above the "Output Editor" section.
Once both these views are ready, you can include the parent view created in Step 1, in your content template for the single TV Series page:
[wpv-view name="view-to-show-seasons"]
I hope this helps and please let me know if any step or segment is not clear.
regards,
Waqar