Skip Navigation

[Résolu] Structure of related pages

This support ticket is created Il y a 7 années et 10 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 38 réponses, has 2 voix.

Last updated by AndreG3332 Il y a 7 années et 9 mois.

Assisted by: Nigel.

Auteur
Publications
#409964

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Hi Andre

I'll take a look if you want to give me the site credentials, I have marked your next reply as private.

#410166

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Hi Andre

I have looked through your views and templates, they were missing the query filters and limits that I talked about in my first long response.

I have modified them to match the versions on my test site so you will notice I have overwritten a couple of things trying to get it to work.

It now should work, but unfortunately still does not, and I have run out of time today to investigate further and am travelling tomorrow and so won't be able to look at it before Monday.

What I have noticed is that you partners archive doesn't work for some reason as yet undetermined. If I set the partner archive so that it doesn't use any filters and just outputs the partner title it should print all partners but says no results found.

If you do any more work on this I would investigate that—or, use the option I originally suggested which was to create a page to display the partner view.

#410945

Hi Nigel,

I am going to try the route of using a page instead of using the the templlate directly. I will keep you up to speed in the net day or two of my progress

#410990

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Thanks for the update Andre, let me know how you get on.

If I have any free time I will take another look at why your partners archive doesn't seem to be working and if I find anything I will let you know.

#413796
view for the partners.png

Hi Nigel,

Sorry had to take a break or two from this project and now i seem to have lost my way again,

What i have at the moment :
Home page
with Categories showing. This is from the view
"Categories table view Home page"
Works 100%
Then clicks on the categories and it opens page

hidden link
with the categories filter ie "emotional"

hidden link

The view that powers this is:
Partner listing with nested Post and Category view. Image attached.

Now the category filter is not working. it is showing all of the partners irrespective of the categories.

I know it has to do with the query filter.

Just to refresh your memory, the structure is Post with taxonomy (category)

and parent of Partner.

Here is the code snippits for the above view.

Loop Output Editor

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
		[wpv-post-body view_template="Loop item in Partner listing filtered by category"]
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/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]

and Templates for this View

[types field='logo'][/types]<br>
[types field='company-name'][/types]<br>
[types field='website'][/types]<br>
[wpv-view name="Post and categories child to partner"]<br><hr>

#414301

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

KTOO8iiTzx.gif

OK, it has taken me a while to re-familiarise myself with how this is supposed to work.

Rather than trying to incrementally move towards a solution which I fear may keep us going round in circles I have gone back to the initial long post where I described the solution and implemented it on a slimmed-down copy of your site, such that it works, and I will describe everything involved below.

The only unexpected behaviour comes from the fact that your categories are nested which produced some false positives when it comes to the results returned, and I would flatten your category hierarchy.

So,
- I took a backup of your site and installed it locally. To abstract away from design issues and to streamline the process I de-activated all plugins except Types and Views, and I switched theme to twentysixteen.

- I turned off custom post types other than partners

- I removed surplus posts, i.e. draft posts, posts categorised as My Story etc., which left me with 10 test posts.

- I changed the parent partner on posts with the categories 'general' and 'parenting' plus one of the 'physical' posts to purple hashtag for testing purposes.

- I deleted all the views and content templates and started over

- I created a simplified categories view with the slug 'post-categories' to add to the home page which displays the post categories. It is a category taxonomy view with no filters.

As per your design the loop output is:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<table width="100%" class="wpv-loop js-wpv-loop">
	<wpv-loop wrap="4" pad="true">
		[wpv-item index=1]
		<tr>
			<td>
				[wpv-post-body view_template="Home page categories"]
			</td>
		[wpv-item index=other]
			<td>
				[wpv-post-body view_template="Home page categories"]
			</td>
		[wpv-item index=4]
			<td>
				[wpv-post-body view_template="Home page categories"]
			</td>
		</tr>
		[wpv-item index=pad]
			<td></td>
		[wpv-item index=pad-last]
			<td></td>
		</tr>
	</wpv-loop>
	</table>
	<!-- wpv-loop-end -->
	[/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]

...and the content template for the view looks like:

<div class="cat-image">
[types termmeta="category-image"][/types]
</div>
<div class="cat-heading">  
<a href="[wpv-archive-link name='partner']?wpvcategory=[wpv-taxonomy-slug]"><h3>[wpv-taxonomy-title]</h3></a>
</div>

- I added the post-categories view via shortcode to the static homepage

- You will note the links go to the partners archive page

- I create a new View with the slug posts-of-a-partner. This will
-- display posts
-- limit the display to just 1 item
-- adds a taxonomy query filter "Select posts with taxonomy: Categories slug in one of those set by the URL parameter wpvcategory"
-- adds a post relationship filter "Select posts that are a children of the current post in the loop."
The loop output and the content template it links to look like so:

<!-- wpv-loop-start -->
	<wpv-loop>
		[wpv-post-body view_template="Posts of a partner loop items"]
	</wpv-loop>
<!-- wpv-loop-end -->

<-- content template -->
<p><a href="[wpv-post-url id="$partner"]?wpvcategory=[wpv-post-taxonomy type='category' format='slug']">[wpv-post-title id="$partner"]</a></p>

- I created a WordPress archive for the Partner post type and in the loop output section added the posts-of-a-partner view I just created, like so:

<!-- wpv-loop-start -->
	<wpv-loop>
		[wpv-view name="posts-of-a-partner"]
	</wpv-loop>
<!-- wpv-loop-end -->

- I created a view with the slug partner-posts-for-category which displays posts, with no limit, that has:
-- a taxonomy filter "Select posts with taxonomy: Categories slug in one of those set by the URL parameter wpvcategory"
-- a Post relationship filter "Select posts that are children of the Post where this View is shown."

The loop output just links to a Content Template like so:

<!-- wpv-loop-start -->
	<wpv-loop>
		[wpv-post-body view_template="Partner posts for category loop item"]
	</wpv-loop>
<!-- wpv-loop-end -->

<!-- the content template -->
<h3>[wpv-post-link]</h3>

- I created a Content Template for displaying single Partner posts. This displays the view partner-posts-for-category that I just created, like so:

<h2>This partner's posts in the chosen category</h2>
[wpv-view name="partner-posts-for-category"]

That's it. You can see the results in the attached screen recording.

I suggest you replicate the steps described above, including deleting views etc to start over, switching theme and deactivating plugins. When you have the functionality working as in my example you can begin to reintroduce your other elements, add styling etc. I will keep my local site available until I know that you have managed to get it working.

#415363

HI Nigel<

thx for that super guide. I did as you instructed, but i did use a brand new installation with just the 2016 Theme and toolset plugin and i created exactly as you said. I do believe i missed something with the "partners archive page"

My results are consistent as expected including this
"- I added the post-categories view via shortcode to the static homepage"

Once i click on one of the categories i am getting null result.

"You will note the links go to the partners archive page"

I did create a "partners archive page" with a slug of "partner"

This is my code for the <a> tag in the post categories view's template section

<div class="cat-heading">  
<a href="[wpv-archive-link name='partner']?wpvcategory=[wpv-taxonomy-slug]"><h3>[wpv-taxonomy-title]</h3></a>
</div>

This is my loop view in the partner archive

[wpv-layout-start]
    [wpv-items-found]
<!-- wpv-loop-start -->
    <wpv-loop>
        [wpv-view name="posts-of-a-partner"]
    </wpv-loop>
<!-- wpv-loop-end -->
    [/wpv-items-found]
[wpv-layout-end]

and the template section

[wpv-view name="Posts of a partner"]

Here is the new url for the clean configuration
hidden link

I can supply you with credentials if you need to have a look at where i messed up.

#415385

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

OK, I've marked the next reply as private, let me have the credentials and I will take a look and see if I can see what went wrong.

#415491

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

The username/password combination don't work for the site link you gave me, could you try again..?

#415885

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Hi Andre

I went through the same steps again, deleting the old views and templates and setting them up from scratch.

I re-assigned some of the content to purple hash tag for testing, and I also flattened the categories.

Although the output is crude, you should now find your site working as expected in terms of functionality.

#416009

Hi Nigel,
You are a star. Thx for you assistance. This has now solved my problems and now I can have some fun getting this site to work.

One last question before we end this amazing "friendship" of the last few week.

Why was it necessary to flatten the categories? That was on specific request of the client and i would need to be able to tell them why this would be an option to have sub categories?

#416154

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

I had to flatten the categories because of the multiple steps involved.

On the home page we are looking at a list of categories. Each of them has a link to the partner archive page with the url parameter wpvcategory added.

When clicking that link we are presented with the partners who have posts in that category.

The problem is not with hierarchical categories as such but with multiple categories assigned to posts, they must only have a single category assigned.

The parters listed on this page also have the wpvcategory url parameter added for the next step. But if you recall how that link is generated, using the view Posts of a partner, we are taking the category of the first post found for partners with posts in the category that comes from the initial wpvcategory parameter. If that post has multiple categories assigned to it then the wpvcategory parameter created for the next step will include all the categories assigned to that post, so the final page won't show just the posts of the initial category but potentially multiple categories.

I hope you can follow that — good luck explaining it to your client!

#416178

So if I understand you correctly, There should only be one category per post never more, because that would potentially create a situation where if two categories were allocated to a post the second category would bring in all the related post for the second category into the final display?

I recon a "because i said so answer may be appropriate here............."

#416199

Nigel
Supporter

Languages: Anglais (English ) Espagnol (Español )

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

Yes, that's exactly right, and it is a consequence of the multi-step solution.

As I mentioned near the start of the thread, a WordPress archive with parametric search could achieve all of this in a single step, and is the solution I would recommended if it were an option.

#416611

Hi Nigel.

I am now trying to add the partner logo to the partner name and im sooooo lost.

it feels as if the whole thing is running in a loop. My first reaction was to add it to the partners archive however the loop output uses the view posts of a partner as the source info.

This is where it is getting very confusing because the above view is using the Post as source for it's information.

The template for post af a partner uses this code for its source:

<p><a href="[wpv-post-url id="$partner"]?wpvcategory=[wpv-post-taxonomy type='category' format='slug']">[wpv-post-title id="$partner"]</a></p>

Would the partner logo be part f this code? and how would it be structured as I am not able to get the logo to show with the name.
I am sorry if this is stupid questions but i am really battling to understand this structure.

The way i see it:
The home page is populated from the "posts categories" view this opens then the archive "partners" . I tried to add the logo here but then it shows all the logos and not just the one applicable.

The partners achieve is populated from the Posts of a partner view that is basically a post view that get filtered so it can not be added here.

And than i became confused.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.