Skip Navigation

[Resolved] Help formatting special View of posts grouped by year and month

This support ticket is created 5 years 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 4 replies, has 2 voices.

Last updated by liatG 5 years ago.

Assisted by: Christian Cox.

Author
Posts
#1230481
Screenshot_Liat 2019-04-05 at 3.22.24 PM.jpg

Hi Christian,
I need help formatting a View based on the Toolset tutorial https://toolset.com/2013/10/how-to-group-views-results-by-year-and-month/.

This ticket is related to questions I still have from this ticket: https://toolset.com/forums/topic/i-want-to-display-the-posts-as-an-unordered-list-within-each-group-of-dates/

I created the blog archive according to the tutorial directions. However, because of the headers within the loop, formatting the View so that it looks good has been difficult. Adding line breaks above the headers results in spaces between all of the posts and extra spaces between headers. I just want the first header to start at the top of the View (no space above) and to have a reasonable amount of spacing after each group of posts (see screenshot).

Page: hidden link.

Thank you for any help you can give me!

#1230666

Hi, custom CSS is a bit outside the scope of what we offer here, but I have a few thoughts to share:
- Technically the only valid child elements of a ul tag are li tags, so the h3 and h4 elements you've added create an invalid HTML structure. That could cause problems with rendering in different browsers. You can remove the ul and li tags and work with divs or spans instead, or refactor the markup to create nested lists of years, months, and posts like
- Year
-- Month
--- Post
--- Post
-- Month
--- Post
- Year
-- Month
--- Post
etc.

- There is no element wrapping each "group" of listings, so there's no way to target the group for a margin-bottom or padding-bottom. Instead you would have to target the top of the next section and add margin or padding there. You can use CSS nth-child selectors to apply different top margin or top padding to the first items if you want.

#1231183

Thank you Christian!

#1231691

Hi Christian,
I was able to use CSS to make the page come out looking the way I wanted. I am posting my code here for anyone who is interested.

I added a top margin to the h4 and h3 headings so they would separate from the lists of posts. I added a negative top margin to the view on the page so that the list wouldn't have abnormally large top margin at the top.

I used text indent to make the lines of text wrap nicely (a hanging indent to line up with the icon I used as a bullet point).

The page:

<div class="blog-archive-top">[wpv-view name="blog-archive"]</div>

The loop editor:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
      [heading condition="year" value="[wpv-post-date format="Y"]"]
<h3 class="blog-heading-top">[wpv-post-date format="Y"]</h3>
[/heading]
[heading condition="month" value="[wpv-post-date format="F"]"]
<h4 class="blog-heading-top">[wpv-post-date format="F"]</h4>
[/heading]
      <div class="extra-padding-left"><div class="lato list-padding special-indent"><a href="[wpv-post-url]"><i class="fas fa-caret-right special-indent"></i>&nbsp;&nbsp;[wpv-post-title]</a></div></div>
	</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]

The custom CSS:

.blog-archive-top {
  margin-top: -1em;
}

.blog-heading-top {
margin-top: .6em;
}

.list-padding {
  margin-left: .2em;
}

.special-indent {
   margin-left: .1em;  
   text-indent: -.5em; 
}

.extra-padding-left {
	margin-left: 1.5em;  
}

.lato {
  font-family: lato;
}
#1231692
Screenshot_Liat 2019-04-16 at 10.56.13 AM.jpg
Screenshot_Liat 2019-04-16 at 10.55.48 AM.jpg

Here is how it looks now. Much more readable. Thank you.

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