Skip Navigation

[Fermé] Views 1.5 Nested Views Ajax Pagination Broken?

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.

This topic contains 11 réponses, has 3 voix.

Last updated by Juan Il y a 7 années et 10 mois.

Assigned support staff: Juan.

Auteur
Publications
#193975

My simple objective is that for every top-level category, I need to display category blocks of posts lists. Ajax pagination must be enabled inside each block. I am able to get everything to display... including pagination controls. However, pagination itself, does not work. Upon pagination, "No items found" is returned. Pagination for the identical view, when not nested, functions perfectly.

I setup a nested view.

View_1 displays the list of posts with default pagination controls that work beautifully. No limit is set on number of posts returned, pagination is set at 5. This setup is functional. I then added a filter to View_1 to only display posts by taxonomy:Categories determined by its parent view.

View_1 Code

	<!-- wpv-loop-start -->
		<wpv-loop>
          [wpv-post-link]
		</wpv-loop>
	<!-- wpv-loop-end -->

View_2 displays Taxonomy: Categories, and I have manually selected the categories. (I need to know how to get it to loop through all top-level categories, without any selection being necessary, so new blocks will be dynamically created as posts are created and categorized... but lets fix pagination first). I then configured it for two columns, and added a bit of sanity checking to make sure it was looping through new categories and to display how many posts were in each displayed category. This works, and everything displays, including paging controls.

View_2 Code

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
	<table width="100%">
    	<wpv-loop wrap="2">
			[wpv-item index=1]
				<tr><td>Category: [wpv-taxonomy-title]</td></tr>
				<tr><td>Post Count: [wpv-taxonomy-post-count]</td></tr>
				<tr><td>[wpv-view name="View_1"]</td></tr>
			[wpv-item index=other]
				<tr><td>Category: [wpv-taxonomy-title]</td></tr>
				<tr><td>Post Count: [wpv-taxonomy-post-count]</td></tr>
				<tr><td>[wpv-view name="View_1"]</td></tr>
		</wpv-loop>
	</table>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		[wpml-string context="wpv-views"]<strong>No items found</strong>[/wpml-string]
	[/wpv-no-items-found]
[wpv-layout-end] 

When I click "next", the list fades away and is replaced by the "No items found" entry. Did I setup something wrong?

#194138

As an update, when two or more NON-NESTED paginated views are present on the same page... the first view works with no problem, but the second and subsequent views do NOT properly execute JavaScript callbacks during their pagination. The posted example from above is pared down and occurs without any additional JavaScript being involved. My final working solution requires JavaScript, but for troubleshooting purposes I created plain and simplified nested views.

#194298

Luo Yang
Supporter

Languages: Anglais (English ) Chinois simplifié (简体中文 )

Timezone: Asia/Hong_Kong (GMT+08:00)

Hi davidT-8,

Thanks for the feedback, I have been able to duplicate same problem in my localhost, and put it into our to-do list, our developers will take care of it.

#194426

Based upon the 1.5 notes, I was under the impression that similar issues were previously discovered and fixed. I look forward to the solution being discovered and implemented. I cannot proceed with multiple projects without it.

#194712

Juan
Supporter

Timezone: Europe/Madrid (GMT+01:00)

Hi David

This is Juan, lead Views developer. I was able to replicate your issue about AJAX pagination not working on nested Views. Let me share some comments.

This is not working and I'm not sure it can be made to work. You see: the setting where we store the current category being displayed by the outer View, used to filter the inner View, is only available during the structure rendering on the first pageload. This means that by the time you click the "Next" link, that setting is gone to its default value, 0. So when you click the "Next" link, the inner View tries to filter by a category with ID set to 0, returning "No posts found".

I don't think we can make that value last longer, but I can offer you a workaround.

Your inner View has a filter by category set by the parent View. Change it into a filter by category, but make it use the "Value set by a shortcode attribute" option. The default shortcode attribute is wpvcategory.

Now, on your outter View you have a shortcode loading this inner View, something like:

[wpv-view name="Your inner View"]

Change it to this:

[wpv-view name="Your inner View" wpvcategory="[wpv-taxonomy-slug]"]

This way, your inner View listing posts will be filtered by the category set on the shortcode attribute of the parent View, and that setting is indeed kept when you perform AJAX pagination.

Please try this and tell me how it goes.

I see you dropped another comment about two different non-nested Views with AJAX pagination not working. I have several of such structures on my test sites and all of them are working fine.Is it possible to see a live example?

Regards,
Juan de Paco

#195002

1. Implementing your change resulted in pagination functionality returning. Unfortunately, only a SINGLE category is cycled through for the actual posts that are shown, though wpv-taxonomy-title and wpv-taxonomy-count DO cycle correctly for each of the four categories that the parent view has selected.
2. The problem I noted with multiple paginated identical views is not non-functional pagination, but non-functional JavaScript Callbacks for ANY of the views AFTER the first view on a page. That problem is ALSO present after applying your suggested workaround.
3. Why not add code into the pagination code to pass category/taxonomy information in and out of the pagination functions, without processing it if necessary, in order to maintain state? Sort of an automatic category/taxonomy callback mechanism?
4. I have a few domains where I can setup a test site online, though currently all of my testing is on an isolated Bitnami/WordPress install. I'd prefer not to go public with specifics too early.

#195020

Okay... scratch item 1. There was a one character typo that resulted in that issue. However, item 2, related to JavaScript callbacks not being applied to additional views on a page, is still wide open.

#195075

Juan
Supporter

Timezone: Europe/Madrid (GMT+01:00)

Hi David

I'm adding your request to our list. It might be a good idea to find a way to pass the "active" term being set on the parent View when needed, and the "current" user too, to make nested Views depending on the outer View info work nicely with AJAX pagination. Good catch 🙂

I'm not sure I follow your other issue, number 2. As I said, I have a lot of examples of pages containing more than one View, even more than two including widgets, all of them using AJAX pagination. The pagination itself works and the callbacks are working fine too. I would need a more concrete description of the issue, a screenshot of the browser console or a way to seethe problem myself in order to understand, find and fix the issue you are experiencing.

Regards,
Juan de Paco

#195651

I updated to the latest version of Views that was just released... nope, that didn't solve anything. Matter of fact, it made things a whole heck of a lot worse when it comes to how wpv-post-featured-image is handled. For example, it has difficulties handing the "raw" feature now, entirely ignores the alt tag ( for example, [wpv-post-featured-image size="full" alt="[wpv-post-title]"] ), and adds in its own data about picture height/width that I never told it to put in there. Whatever happened... it wasn't necessarily for the better.

I'm working on getting up a site on a domain you can reach. When its up, how should I notify you off board?

#195675

Juan
Supporter

Timezone: Europe/Madrid (GMT+01:00)

Hi David

I really think that I'm missing something here.

First of all, about the AJAX callbacks issue. Yes, please set up somewhere I can take a look at, because I need some more extra information about this. I still do not know what is wrong, and I'm actually interested in checking what is not working and why.

Now, on the wpv-post-featured-image shortcode, some notes:
* We have only made a small change when both raw="true" and size="full". In any other scenario, we have changed nothing, so it should work like it worked before. Please be more specific about what particular example is not returning what you expect and why.
* The wpv-post-featured-image shortcode does not have an alt attribute and did not have it before, so it's not that it's now ignoring it: it's just that this is not how you pass the alt attribute. Use this instead:

[wpv-post-featured-image attr="alt=[wpv-post-title]"]

About this, I take note of the suggestion: maybe having specific attributes for setting the alt, title and classname could be nice. Also, be careful about this: if the wpv-post-title shortcode returns anything containing a double qoute,the featured image shortcode will be broken.
* The code used to generate the output for the wpv-post-featured-image shortcode when raw and data attributes are not set (meaning, when we actually return an IMG tag) has not changed either. It returns the IMG tag generated by WordPress for the get_the_post_thumbnail() function. It usually generates the height and width HTML attributes for the IMG tag, and as far as I know this has been this way forever. So it was being displayed this way before too, whether you told it or not. However, it should not be a problem since you can then change how it is displayed using CSS.

Please leave a comment here when you have the test site ready. I will send you an email so we can share that information in private.

Regards,
Juan de Paco

#195960

With respect to the AJAX callback issue, I'm almost finished setting up an external site to show you what I'm talking about, both with vastly simplified code, and my "production" code that I'm working on.

With respect to the wpv-post-featured-image issue...

Here's how things have changed for me since you updated wpv-post-featured-image from 1.5 to 1.5.1.

INPUT CODE

This is the code I was using for images in tooltips in both 1.5 and 1.5.1 (that I will now have to alter and test).

[wpv-if image="_thumbnail_id" evaluate="!empty($image)"]
	<p class="show_thumbnail">
		<img src="[wpv-post-featured-image size="full" raw="true" alt="[wpv-post-title]"]">
	</p>
[/wpv-if]

VIEWS 1.5 DEBUG RELEVANT OUTPUT

This is the debug output from Views 1.5 of code that *works* according to my requirements (with CSS, it will show a non-cropped/non-zoomed full image 75 pixels wide and appropriately scaled in its original aspect ratio).

wpv-if:
Attributes: {"image":"_thumbnail_id","evaluate":"!empty($image)"}
Info: Conditional output: evaluated to true
Output:

<p class="show_thumbnail">
	<img src="[wpv-post-featured-image size="full" raw="true" alt="Sanitized Post Title"]">
</p>

wpv-post-featured-image:
Attributes: {"size":"full","raw":"true","alt":"Sanitized Post Title"}
Output:

<em><u>hidden link</u></em>

FINAL VIEWS 1.5 HTML OUTPUT

With the input code and Views 1.5, this is the HTML rendered.

<p class="show_thumbnail">
	<img src="<em><u>hidden link</u></em>">
</p>

VIEWS 1.5.1 DEBUG RELEVANT OUTPUT

In Views 1.5.1, this is the Views debug output. This indicates that the new wpv-post-featured-image significantly altered something inside to where it is not returning *any* output.

wpv-if:
Attributes: {"image":"_thumbnail_id","evaluate":"!empty($image)"}
Info: Conditional output: evaluated to true
Output:

<p class="show_thumbnail">
	<img src="[wpv-post-featured-image size="full" raw="true" alt="Sanitized Post Title"]">
</p>

wpv-post-featured-image:
Attributes: {"size":"full","raw":"true","alt":"Alien slaughterpalooza Infested Planet invades PC, Mac in March"}
Info: Filter wpv-post-featured-image applied
(NO OUTPUT DISPLAYED)

VIEWS 1.5.1 HTML OUTPUT

This is the result of the input code being passed through Views 1.5.1.


<p class="show_thumbnail"> <img src=""> </p>

Using your suggestion to alter my code...

[wpv-if image="_thumbnail_id" evaluate="!empty($image)"]
	<p class="show_thumbnail">
		<img src="[wpv-post-featured-image size="full" raw="true" attr="alt=[wpv-post-title]"]">
	</p>
[/wpv-if]

In Views 1.5, the images display, but with no alt attribute. In Views 1.5.1, no image displays at all... the output is identical to the previous Views 1.5.1 output.. blank.

Simply removing the IMG tag encapsulating the wpv-post-featured-image does not alter the blank output in Views 1.5.1. Removing the IMG tag *and* the raw="true" results in the following output:

<img width="530" height="298" src="<em><u>hidden link</u></em>" class="attachment-full wp-post-image" alt="Sanitized Post Title" />

Width, Height, and CSS Class tags have been added, that I did not request. Ultimately not the end of the world. Strangely, though, sometimes the alt tag is the post title, other times its the file name of the image. Also of note... while the image used was correctly the "full" one, indicated by width/height... it chose a "thumbnail" named one... also unexpected. Neither issue is on my radar... yet.

AJAX/Callbacks has priority for me.

#195979

Juan
Supporter

Timezone: Europe/Madrid (GMT+01:00)

Hi David

I just tested again on my local and everything is working fine for me.I tested with different combinations and in all the cases the shortcode returned the expected result. At this point, it might be better if I could take a look at this myself and perform some checks. Anyhow, I see some things strage at your code. Look at the old one you were using and the new one based on my advice:

<img src="[wpv-post-featured-image size="full" raw="true" alt="[wpv-post-title]"]">
<img src="[wpv-post-featured-image size="full" raw="true" attr="alt=[wpv-post-title]"]">

In both of the cases, the alt and attr attributes won't ne applied. You are using the wpv-post-featured-image shortcode to get just the image URL and use it inside the src attribute. I do not understand how could it apply the alt attribute. If you are building the IMG tag manually, then you need to set the attributes like alt or title manually,outside of the wpv-post-featured-image shortcode.
If you do not use the raw="true" attribute, the IMG tag is automatically generated and it includes the width and height attributes (and you can not avoid it,no matter if you want or not) and the alt attribute comes from the media metadata itself, that you can alter when editing the image.

I'm sending you a private email right now, so we can solve this and the other issue about the AJAX callbacks.

Regards,
Juan de Paco

Le sujet ‘[Fermé] Views 1.5 Nested Views Ajax Pagination Broken?’ est fermé à de nouvelles réponses.