Quantcast
Channel: Toolset » All Posts
Viewing all articles
Browse latest Browse all 20145

Reply To: [Assigned] wpv-if with a Views

$
0
0

Dear Pat,
Thanks for the feedback and clarification. I fixed this issue in your site. The following are fixes applied:

a.) In Concours content template, I remove the wpv-if because it's not possible to check the Views output with that condition. And then I wrapped it with span using class name of "photoconcours_block". This signifies everything under this span is the photo concours block.
Example:

    <td colspan="2"><span class="photoconcours_block"><h2>Les photos du concours</h2>[wpv-view name="Photos concours"]</span></td>

b.) In the View "Photos concours" layout HTML, I change the [wpv-no-items-found] FROM:

[wpv-no-items-found][wpml-string context="wpv-views"]<strong>Pas encore de photos sur ce concours !</strong>[/wpml-string][/wpv-no-items-found]

TO:

[wpv-no-items-found]<div class="no_photos"></div>[/wpv-no-items-found]

This is an empty div with class "no_photos" that outputs nothing

c.) Finally back to the "Concours" content template, click "Open JS editor" and I add this JS code which will check if <div class="no_photos"></div> exists (in this case, no photos to be shown):

jQuery( document ).ready(function($) {
  //$("#js-main-map-canvas").wpvmap();

    var myDiv = $('.no_photos');
    console.log(myDiv);
    if ( myDiv.length){
        //no photos div exist, hide the photo concours block
        $('.photoconcours_block').hide();
    }

});

If there is no photo, don't show the photo concours span block. Otherwise; show it along with the View and the rest. By the way, I commented this line:

  //$("#js-main-map-canvas").wpvmap();

Because its throwing JS errors.

I added a test concours page that does not have photos:
/concours/test-concours-photo/

When you visit this page, the page block is not shown (because no photos is set). However it is shown in your example: /concours/cheval-passion-2014/
I believe there are other ways in solving this but this is the simplest way I can think of and does not take much time. Please let me know how it goes. Thanks.

Cheers,
Emerson


Viewing all articles
Browse latest Browse all 20145

Trending Articles