Formidable Forms

The Most Advanced WordPress Forms Plugin and Form Builder

  • Features
  • Pricing
  • Blog
  • Support
  • Login
  • Get Formidable Forms

How to sort a view across multiple pages

Last Updated: July 8, 2020

Knowledge Base → Views → Examples → How to sort a view across multiple pages

Learn how to show form submissions on a page, and sort a view across pages. This allows users to sort by values on the page, including values that are shown on a different page when using pagination. If your view is a table without pagination, read how to make a sortable table. Note: This isn't set up to work with Dynamic fields.

Create the view

If you haven't created a view yet, start there.

Add links to sort

Once your view is complete, add links to sort the data. For example, you may have a table header that looks like this:

<th>Date</th>

This label needs to be switched to a link.

<th><a href="?frmsort=25&frmdir=[if get param='frmdir' equals='asc']desc[/if get][if get param='frmdir' not_equal='asc']asc[/if get]">Date</a></th>

In this link, replace 25 with the id of the field to order by when 'Date' is clicked. Now, each time you click this link it will switch between frmsort=25&frmdir=asc and frmsort=25&frmdir=desc to change the direction of the sorting.

Formidable Forms is the best WordPress Form Builder plugin. Get it for free!

Add as many different sorting links that you would like. Be sure to change the field id in each link.

Sort the view

All that is left is to tell your view how to use the frmsort and frmdir values. To do this, we'll need a custom shortcode that uses the PHP alternative to insert a view.

add_shortcode( 'sort-frm-view', 'sort_frm_view_shortcode' );
function sort_frm_view_shortcode( $atts ) {
  if ( isset( $_GET['frmsort'] ) ) {
    $atts['order_by'] = sanitize_text_field( $_GET['frmsort'] );
  }
  if ( isset( $_GET['frmdir'] ) ) {
    $atts['order'] = sanitize_text_field( $_GET['frmdir'] );
  }
  return FrmProDisplaysController::get_shortcode( $atts );
}

Insert the view on a page

Since you have a custom shortcode, the view will be inserted on the page a bit differently than normal. Now you will use 'sort-frm-view' in place of 'display-frm-data' in your shortcodes. If your original view shortcode looked like this:

[display-frm-data id=150 filter=limited limit=10]

the new shortcode will be:

[sort-frm-view id=150 filter=limited limit=10]

Dynamically sort the content

Now the order of entries in the view will change each time a link is clicked. This covers any number of fields that you would like to sort.

  • Create the view
  • Add links to sort
  • Sort the view
  • Insert the view on a page
  • Dynamically sort the content
Categories
×

Categories

  • Installation & Getting Started
  • Account Management
  • Forms
  • Entries
  • Views
  • Styles
  • Importing & Exporting
  • Add-Ons
  • Extend Formidable Forms
Install Formidable Lite

Using WordPress and want to get Formidable Forms for free?

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

Take on bigger projects Right Now

Get the tools you need to revolutionize your workflow and architect a masterpiece. Build the most advanced WordPress forms and actually use the data you collect in meaningful ways.

Get the most advanced WordPress form plugin and the only form builder with integrated Views.

Get Formidable Forms Now

Resources

  • Community
  • Affiliates
  • Contact

Top Features

  • Front End Editor
  • Repeating Fields
  • Views from Entries
  • Calculator Forms
  • Conditional Logic
  • Visual Form Styler
  • Form Templates
  • User Submitted Posts
  • File Upload Forms
  • Spam Protection
  • Multi Page Forms
  • Surveys & Polls
  • Form Graphs & Charts
  • Save and Continue
  • Mobile Forms
  • Stripe Forms
  • PayPal Forms
  • WooCommerce Forms
  • MailChimp Forms
  • User Registration
  • Signature Forms
  • Bootstrap Forms
  • Quiz Maker
  • Zapier Forms
  • Salesforce Forms
  • HubSpot Forms
  • API Webhooks
  • Multilingual Forms
  • Directories

Company

  • About Us
  • Giving Back
  • Careers
  • Newsletter
  • Blog

Copyright © 2021 Strategy11, LLC. Formidable Forms® is a registered trademark Strategy11, LLC.
Privacy Policy | Terms of Service | Sitemap

Join 300,000+ using Formidable Forms to create form-focused solutions fast. Get Started