Skip Navigation

[Resolved] How to build a Bible Study Tool with WP Types Views

This support ticket is created 6 years, 11 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.

Our next available supporter will start replying to tickets in about 8.75 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#601519

Hi,
First, I'd like to thank every support member for the generous help and speed of response.
Second, I'd like to express my gratitude to the Types team and the WPML team. My websites are basically built on them.

Third, I have been waiting for close to 2 years now to come to the step of building this Bible study tool using the WP types, so I appreciate your help in this.

I will show you a complete system here, and need to know:
1- if all or part of this system can be built using Types or not. (it does not have to be identical, it can be similar with the same functions)
2- if I can get help using this forum or I need to pay extra money for support or customization.

here is the system:
hidden link
1- You start with a search bar where you can search for a word in one of the Bible translations in the dropdown menu:
hidden link
.
2- you can choose a Bible book from a menu that opens when you click "Bible Book List"
hidden link
.
3- Say you chose "Genesis", another menu opens with the specifi number of chapters related to Genesis:
hidden link
.
4- Say you clicked on "9",
you go to this page:
hidden link

Here you see a page with the Text of Genesis 9 and version "KJV".
you can then change the version from the dropdown list to "New English Translation (NET)", so you automatically go to this page:
hidden link
.
This is the most important option for me:
-------------------------------------------------------------
5- you can click on this icon to open a passage comparison tool:
hidden link
where you can compare 2 different translations:
hidden link
and change the translation you want.

if you then clicked on the "X", you go back to one version.

Initial thoughts:
- shall I create a post per chapter in each translation? this will be thousands of posts.
- shall I create one post per chapter that has multiple custom fields to fill?
- I know that there is a search bu url parameter in the Views plugin, but how to utilize it in this way?

if you can please please put me in the right direction, at least with some initial push, so I can utilize your great plugin better.

thanks in Advance.

#601616

Let me start by saying thanks for considering Toolset for your project. What I'm seeing here is fairly complex, and it's difficult for me to definitively say "Yes" or "No" for each piece of the application, and it's very difficult for me to say "this is the best way to set it up". In my experience, it's best to try to replicate any system on a very small scale so that you can see what is or is not possible. When you get stuck, create a ticket to discuss your options for implementing individual features. It's just not practical for us to consider all the possible options and functionality in a single ticket - each answer opens up 10 new questions and the ticket becomes difficult to follow. With that being said, please find my general answers to your questions below. I do encourage you to set up a trial and create individual tickets for each issue so we can explore in more detail.

1- You start with a search bar where you can search for a word in one of the Bible translations in the dropdown menu.
Okay I assume this is a custom search View with text search filter and a custom field filter. To start with an empty result set, you may need to add some custom code. I have a sample you can use:

add_filter( 'wpv_filter_query', 'drop_empty_search_query', 10, 3 );
function drop_empty_search_query( $query_args, $view_settings, $view_id ) {
    $ids = array(1, 2, 3);
    if (in_array($view_id, $ids)){
      if ( isset($_GET['wpv_post_search']) && $_GET['wpv_post_search'] != '' )
      {
      } else {
        $query_args['post__in'] = array(0);
      }
    }
    return $query_args;
}

This code checks the URL parameter wpv_post_search. If the URL param is present, it means some search term has been submitted and results should be displayed. If not, no results should be displayed. We support this filter here in the forum, but customization not directly related to the API might require extra development.

2- you can choose a Bible book from a menu that opens when you click "Bible Book List"
We can help you set up a View that shows all the possible books in a list like this, but using these list items as triggers to show or hide other portions of the screen will require your own custom interface design and code. That falls outside the scope of what we provide here in the forums.

3- Say you chose "Genesis", another menu opens with the specifi number of chapters related to Genesis:
We can help you set up a View that shows all the possible chapters in a selected book, but showing and hiding these elements based on your selections will require custom code.

Here you see a page with the Text of Genesis 9 and version "KJV".
you can then change the version from the dropdown list to "New English Translation (NET)"

It's possible to set up a View that allows the User to filter posts by a custom field, so you could use a custom field on these posts to define a translation version. You would also need some way to limit the results to just the translations of this specific chapter. To do that, you could filter by slug or post title or a different custom field. The links you set up on the main menu can be constructed in a way that directs the User to the correct URL. There are lots of moving parts here, and this answer is very general.

5- you can click on this icon to open a passage comparison tool:
Something exactly like this will require a good deal of custom code that we do not provide or support here in the forums. Here's what we can accomplish:
- Use URL parameters to determine which 2 translations should be displayed
- Use a View to display 2 translations
- Use a View to display a single translation
- Create links to navigate between the comparison layout and the single translation layout

Here's what is not as simple:
- Using a single variable "&version=NIV;KJV" to determine the layout of the page, whether to show a single version or compare two versions. You may need some custom PHP code to help with this. If the URL parameter structure is flexible, we can probably come up with a solution that does not require additional PHP.

where you can compare 2 different translations:
hidden link
and change the translation you want.
I'm not sure I understand what you mean to change the translation you want. If this means that you just want to redirect to the single translation layout with this translation displayed, then this is possible without any custom code.

- shall I create a post per chapter in each translation? this will be thousands of posts.
- shall I create one post per chapter that has multiple custom fields to fill?

Separate posts - this makes searching and filtering posts easier, but there will be more posts in your database and in wp-admin. This can slow down your site as the number of posts grow, but a good caching plugin can help with that problem.
Different custom fields - This approach is less flexible for text-based searching and View filtering, but there will be fewer posts in your wp-admin and database. I recommend setting up some custom search Views to see what you can accomplish and observe the limitations of each approach.

- I know that there is a search bu url parameter in the Views plugin, but how to utilize it in this way?
Views can use URL parameters to define filter conditions without any extra code needed. If you need to access URL parameters outside of PHP you can use this shortcode:

add_shortcode( 'wpv-post-param', 'wpv_post_param_shortcode' );

function wpv_post_param_shortcode( $atts ) {
  if ( !empty( $atts['var'] ) ) {
    $var = (array)$_GET[$atts['var']];
    return esc_html( implode( ', ', $var ) );
  }
}

For example, to access the value of the "testing" URL parameter in a conditional or in your page content:

[wpv-post-param var='testing'] (this will print 123 to the screen)
[wpv-conditional if="([wpv-post-param var='testing'] eq '123')"]
  do something if the parameter is '123'
[/wpv-conditional]

If you need to do any parsing of URL parameter values beyond simple "equals", this will require additional code that falls outside the scope of our support forum. For instance, in the URL structure you currently use, multiple values are separated by a semicolon like variable=abc;def. This exact URL format isn't supported, but if it's okay to be flexible we could come up with another approach.

#602267

Hi Christian,
I was waiting till we close off the other ticket so we can continue this ticket, but in order not to get this ticket closed:

1- you said:

Here's what we can accomplish:
- Use URL parameters to determine which 2 translations should be displayed
- Use a View to display 2 translations
- Use a View to display a single translation
- Create links to navigate between the comparison layout and the single translation layout

.
2- You also said:

This exact URL format isn't supported, but if it's okay to be flexible we could come up with another approach.

I am very flexible. I am still building the site and can accommodate any requirements, can you please suggest the alternative approach?

Thanks.

#602348

I think you could use multiple URL parameters instead of a semi-colon in one parameter to accomplish something similar.
- One URL parameter could be used to determine the layout of the page. You need to know whether to show one translation, or to compare two translations. For example the parameter could be "compare=1" if you want to show two translations at the same time. If you remove the "compare" parameter, that would indicate no comparison and only the first translation would be shown.
- One URL parameter could determine the 1st translation. For example, the parameter could be "t1=kjv", meaning the first translation should be King James Version.
- One URL parameter could determine the 2nd translation. For example, the parameter could be "t2=niv", meaning the second translation to compare should be the New International Version.

Then in your Content Template you can use the wpv-post-param shortcode I mentioned earlier to test each of these URL components. Based on the values, you can modify the output to show one or two columns, and show the correct translations. Within each translation, you can use links to add or remove URL parameters as necessary. For example, if you are comparing two translations, the "X" or close button in translation 2 should point to a URL without the compare parameter or the t2 parameter. Then when the user clicks the link, they will be redirected to the correct URL.

#602763

Hi Christian,

Thanks for the thoughts.
ok So to start, how can I display a certain layout based on a url parameter (e.g. compare=1)? I tried to create a layout, but there were no options to specify such parameters?

(by the way, the conditional layout can be a solution for my other ticket, I can specify a certain layout if the compare=0, or so, to show the text of a certain field).

so can you please guide me as to how to change the layout conditionally?

thanks

#602956

Basically it means you create a Content Template or Content Layout for the page that includes both designs - one column and two columns. You then use conditional HTML to display the proper design based on a URL parameter. Here is a very simple example:

<div>This is column 1.</div>
[wpv-conditional if="([wpv-post-param var='compare'] eq '1')"]
<div>This is column 2.</div>
[/wpv-conditional]
#604096

Hi Christian,
thanks a lot for the conditional you provided.

Can you please elaborate on the following points:

1- is this conditional supposed to be in the Loop wizard section? (so I replace the content with this donditional then add the relevant custom fields to show the text?

2- if so, then in the 2 column case (when compare=1), how to control which translation appears in the second column?

3- Also, how to show a dropdown list with the available translations to show something like this?
hidden link

(or something close to it)

thanks,

#604148

1- is this conditional supposed to be in the Loop wizard section?
I was thinking the conditional would be in the custom search page Content Template or Template Layout. Each column would include a View filtered by translation as a shortcode attribute. Then you can pass the appropriate parameter value into each View.

2- if so, then in the 2 column case (when compare=1), how to control which translation appears in the second column?
You can pass the proper translation filter code into View 1 and View 2 using a shortcode attribute. I mentioned this technique in the comment above: https://toolset.com/forums/topic/how-to-build-a-bible-study-tool-with-wp-types-views/#post-601616

Left column
[wpv-view name="your-view-slug" translation="[wpv-post-param var='t1']"]

[wpv-conditional]
Right column
[wpv-view name="your-view-slug" translation="[wpv-post-param var='t2']"]
[/wpv-conditional

3- Also, how to show a dropdown list with the available translations to show something like this?
A custom search View filtered by translation will show all the available translations in a filter like this by default.