Skip Navigation

[Resolved] ABC Filter with taxonomie

This support ticket is created 7 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
- 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+00:00)

Tagged: 

This topic contains 34 replies, has 3 voices.

Last updated by HenrykI1899 7 years, 3 months ago.

Assisted by: Nigel.

Author
Posts
#467872

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Hi Henryk

You are welcome to try the betas but I'm not sure they are going to make much difference to what we are aiming to set-up, though if you have found a bug—your deleting layouts problem—then it may be resolved in the beta.

But please make sure you have a backup before you do install the betas. And bear in mind that there are some major changes being introduced to Layouts 1.9 which is why a beta has been made available so that we can identify issues and bugs from user feedback, so some bugs may be fixed, but others could be introduced.

I'll update you this afternoon about the main issue.

#467960

Nigel
Supporter

Languages: English (English ) Spanish (Español )

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

Screen Shot 2016-12-15 at 18.00.16.png
alpha-filter.gif

OK, Henryk

Let's sort of start again.

First, an obligatory screen recording which shows my alphabet filter working across two different post type archives for films and books. It would work on as many post types as you wanted.

Next, a word or two about my test site versus your site.

It's much quicker for me to work in a simple environment with a standard theme such as twentysixteen and just using Types and Views, not Layouts. It will work in Layouts, but I know it has caused some confusion, so let me clarify a couple of things for you, after which you should be able to make sense of the layouts and archives on your site so that you can delete those which are no longer required.

When you have Layouts activated it intervenes in the normal process where WordPress uses PHP templates to generate pages, and if a layout is assigned the page will be generated by Layouts using the corresponding layout instead. A page may be an actual page or post, or a 'virtual' page such as a custom post or taxonomy archive.

So if you assign a layout to the fussballer archive, for example, it will be used to generate the page whenever the corresponding url (e.g. mysite.com/fussballer/) is entered. The page will output whatever you add to the layout. If you don't enter an archive cell, then it won't actually output the archive. If you just entered a Visual Editor cell with the text "the fussballer archive is supposed to go here" then that is all you would see when you visited mysite.com/fussballer/.

When you do add a WordPress archive cell it will generate a new custom WordPress archive view for you. That will be listed at Toolset > WordPress Archives, and if you have already made a custom archive previously at that page then you can use that existing archive in the archive cell of your archive layout.

That sounds like a lot of archives, but there are basically two concepts here. The archive layout which takes control of what is generated on the page at the url for an archive, and the custom WordPress archive view which you add using an archive cell which actually generates the content.

Hopefully that's clear. Back to the alphabet 'filters'.

So, we have our alphabet taxonomy, no change there.

You will, of course, need to apply this taxonomy to your trainer, vereine, and fussballer posts.

The one change is that, as you saw in the other thread, I had to create a simple custom shortcode to generate the url for the current page minus any url parameters. (It may be possible with the Toolset shortcodes, but I just couldn't find any combination that would work.)

This is to generate the 'All' link to show all posts and remove any existing letter filter.

So, you will need to add the following code to your theme's functions.php file, or you can add it via a plugin such as Code Snippets where you can add the code via the admin pages.

/**
 * Register custom shortcode to output url of current page
 * Minus any url parameters
 */
add_shortcode( 'current_url', function(){
 
    $request = $_SERVER['HTTP_HOST'].strtok($_SERVER["REQUEST_URI"],'?');
    $protocol = '<em><u>hidden link</u></em>';
 
    if ( $_SERVER['HTTPS'] ) {
        $protocol = '<em><u>hidden link</u></em>';
    }
 
    return $protocol . $request;
} );

Now edit your alphabet taxonomy view to include the All link, and to change how we generate the links for the letters, which will keep us on the same page, the current custom post archive page.

Your loop output section will look like this:

[wpv-layout-start]
	[wpv-items-found]
	<a href="[current_url]">All</a>
	<!-- wpv-loop-start -->
		<wpv-loop>
			<a href="?wpvalphabet=[wpv-taxonomy-title]">[wpv-taxonomy-title]</a>
		</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]

Now, if you haven't already, create archives for your custom post types, they will each work the same way. I created mine in Toolset > WordPress Archives, you can do so by assigning a layout to the archive and then in that layout inserting an archive cell.

Here we add a taxonomy query filter. See my screenshot.

In the previous step with the alphabet taxonomy view we pass the letter we want to filter by as a url parameter 'wpvalphabet' to the custom post archive, where we take that url parameter and use it to filter our custom posts by the alphabet taxonomy.

Then in our loop output editor we need to add our alphabet taxonomy view to render the letter filters. Note that I moved it outside the items-found block so that it still renders if there are no posts for that letter.

[wpv-layout-start]
[wpv-view name="alphabet-terms"]
[wpv-items-found]
<!-- wpv-loop-start -->
		<wpv-loop>
			<h3>[wpv-post-link]</h3>
		</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]

I think that's it, let me know how you get on.

If you find that you are having problems deleting unwanted layouts etc., could you please open a new ticket with that issue and keep this one to the original ABC filter?

Thanks.

#468457
vereins-a-z1.PNG
vereins-a-z2.PNG

Hi Nigel,
thanks for your hard work. But thats all not so clear. most of the thinks i have done. the A-Z is not working. the "Alle" works. Here some questions:

the taxonomy Filter url is like:
<a href="?wpvabisz=[wpv-taxonomy-title]">[wpv-taxonomy-title]</a>

<I find some code "[wpv-post-body view_template="None"]"
is this code useless?

For each A-Z Taxononmie (Trainer, Vereine, Fussballer) I now have 1x view, 2x Layoutarchive, 2x WordPressarchive, 2 x Contenttemplates.

I would like to change the "Vereine" first:

hidden link

hidden link

hidden link

hidden link

hidden link

hidden link

hidden link

<But in your code I can´t see the code to the content template. Or don´t I need this?

I hope you can see what is not working with "Vereine"
thanks Henryk

#468466

Hi Nigel,
now it works , but the "A" Taxonomy don´t. Maybe a problem with the relevanssi plugin. I will make the index new tomorow.

And I have now an url. Thats not so bad, but after linking to maybe
hidden link
hidden link
I can´t see the content (Name, Nationaliäten, Landesverbände)

#468621

Hi Nigel,
all is ok and working. I fixed all problemes myself.
thank you for your solution. Please make a dokumentationsite for this. That would help other people. A mix of my problem and the categorie version. Maybe i need the categorieversion later on. I now know how to do so.
thank you very mutch for this good solutition.
Henryk

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