Skip Navigation

[Resolved] Split: View not working as expected

This support ticket is created 2 years, 3 months 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 2 replies, has 2 voices.

Last updated by vitoC 2 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2430297

Hi Waqar,
I was able to go ahead if you go to this page: hidden link

the remaining problems are:

1) I inserted a filter with select that filters posts based on a custom field "Document year" but this filter is not visible, if I view the code with chrome inspector I see the form but there is a display: none and I don't understand why

2) I have to view the documents based on another custom field called "Document language", when this field is equal to the string "Italian" I have to insert the documents in the page with Italian language, when it is equal to the string "English" I have to view the documents on the page in English. As if there was an automatic filter based on the language of the page linked to the "document language" field ... can it be done?

3) I would like to insert only the "Post title" in the document loop and then clicking on the title I have to open the pdf ... currently you can see both the title and the url of the pdf. How can I do?

I deleted the unused views and templates
Thank you

#2430535

Hi,

1). When I checked the page, I was able to see the "Document year" search filter, in both languages.

Screenshot - Italian: hidden link
Screenshot - English: hidden link

Looks like you've managed to make it work after writing to us.

2). To filter the view's results, based on the current language and the "Lingua Documento" field, you can use a custom function attached to the 'wpv_filter_query' hook:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

For example:


add_filter( 'wpv_filter_query', 'wpv_filter_query_func', 1000 , 3 );
function wpv_filter_query_func( $query_args, $view_settings ) {
    
    // process if specific view
    if ( ( isset($view_settings['view_id']) && $view_settings['view_id'] == 25325) ) {
        
        $current_lang = apply_filters( 'wpml_current_language', null );

        if($current_lang == 'it') {
            $query_args['meta_query'][] = array('key' => 'wpcf-lingua-documento', 'value' => 'italiano', 'type' => 'CHAR', 'compare' => '=');

        } elseif ($current_lang == 'en') {
            $query_args['meta_query'][] = array('key' => 'wpcf-lingua-documento', 'value' => 'inglese', 'type' => 'CHAR', 'compare' => '=');
        }
    }
    return $query_args;
}

The above code snippet can be included through either Toolset's custom code feature ( ref: https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/ ) or through the active theme's "functions.php" file.

3). You currently have this code in the loop of the view:


....
<wpv-loop>
	<li style="list-style:none; margin-left:0">
		[wpv-post-title]
		</br>
		<div class="button-ricerca">
			<a href=" [types field='capitolo-osservatorio' output='raw'][/types]" class="mk-button js-smooth-scroll mk-button--dimension-flat mk-button--size-large mk-button--corner-pointed text-color-light _ relative text-center font-weight-700 no-backface  letter-spacing-2 inline" target="_blank">Scarica documento</a>
		</div>
	</li>
</wpv-loop>
....

To make the post title and document link, show as one, you can update it to:


....
<wpv-loop>
	<li style="list-style:none; margin-left:0">			
		<div class="button-ricerca">
			<a href=" [types field='capitolo-osservatorio' output='raw'][/types]" class="mk-button js-smooth-scroll mk-button--dimension-flat mk-button--size-large mk-button--corner-pointed text-color-light _ relative text-center font-weight-700 no-backface  letter-spacing-2 inline" target="_blank">[wpv-post-title]</a>
		</div>
	</li>
</wpv-loop>
....

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

regards,
Waqar

#2432007

My issue is resolved now. Thank you!