Skip Navigation

[Resolved] Empty columns don’t hide

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a Bootstrap-grid View that works fine on desktop, but when I check it in mobile View you can see that there is empty space at the end of the results. Extra empty result containers are being shown.

Solution: Remove all container elements from the pad and pad-last items. Make sure the wrap and index numbers are set up correctly.

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
    <wpv-loop wrap="4" pad="true">
        [wpv-item index=1]
        <div class="row">
            <div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
        [wpv-item index=other]
            <div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
        [wpv-item index=4]
            <div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
        </div>
        [wpv-item index=pad]
        [wpv-item index=pad-last]
        </div>
    </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
[wpv-layout-end]

Relevant Documentation:
https://toolset.com/documentation/user-guides/digging-into-view-outputs/

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

This topic contains 5 replies, has 3 voices.

Last updated by CommMgr 6 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#949338
advisory_board_column_space_on_phone1.jpg
advisory_board_column_space_on_phone2.jpg

I am using Tools and Views plugins on our Advisory Board page. hidden link

The page is setup with views in a 4 column grid. On desktop and tablet, the grid performs correctly.

In phone view, the last column shows empty columns if there are less than 4 entries (see screenshots for reference).

I need assistance hiding the columns on phone view if they are empty.

Thank you for your assistance.
CommMgr

#950106

Those empty columns are there on desktop as well, as you see in your own screenshot.

It's due to the HTML being rendered, of course, even if the Field is empty

You can use conditional HTML to not output certain HTML if there is nothing to output.
But a GRID needs to be output - otherwise the grid breaks.

So, here you could use the index and padding attributes that get generated:

<wpv-loop wrap="3" pad="true">
		[wpv-item index=1]
		<div class="row ">
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in asdfadsf"]</div>
		[wpv-item index=2]
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in asdfadsf"]</div>
		[wpv-item index=3]
			<div class="col-sm-4">[wpv-post-body view_template="Loop item in asdfadsf"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-4"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-4"></div>
		</div>
	</wpv-loop>

The last are what is output if you do not have content.
More details here:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-item

#956468

Hi, Beda...

Thank you for replying. I will use the code you provided and let you know if it works.

Thank you for your help,
CommMgr

#956469

Hi, Breda...

I just used the code you provided and it didn't work. Empty columns are still appearing in phone view.

Here is the code I am using:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop wrap="4" pad="true">
		[wpv-item index=1]
		<div class="row">
			<div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
		[wpv-item index=2]
			<div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
		[wpv-item index=3]
			<div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
		</div>
		[wpv-item index=pad]
			<div class="col-sm-3 advisory_board_column"></div>
		[wpv-item index=pad-last]
			<div class="col-sm-3 advisory_board_column"></div>
		</div>
	</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
[wpv-layout-end]

Thank you for your help.
CommMgr

#956636

Hi, try this version instead:

[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
    <wpv-loop wrap="4" pad="true">
        [wpv-item index=1]
        <div class="row">
            <div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
        [wpv-item index=other]
            <div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
        [wpv-item index=4]
            <div class="col-sm-3 advisory_board_column">[wpv-post-body view_template="Loop item in Advisory Board List - End User"]</div>
        </div>
        [wpv-item index=pad]
        [wpv-item index=pad-last]
        </div>
    </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
[wpv-layout-end]

The pad and pad-last items are there to help you fill in empty space with placeholder information, if you want. In your case, I don't think you want placeholder information. You want trailing spaces to be left blank with no placeholders, so I have removed the content from those items. I kept the closing div after pad-last because it's necessary to close the row out when fewer than 4 items occur in the last row.

Also your wrap is 4 instead of 3, so the indexes had to be modified. Items 2 and 3 are identical, so they are covered by index "other". Item 4 has the extra closing div for the row. For more information about this, you can read more about Loop structures here: https://toolset.com/documentation/user-guides/digging-into-view-outputs/

#956639

Thank you, Christian...that code worked perfectly. I appreciate your assistance.

CommMgr