Avatar of Graeme McGilvray
Graeme McGilvray
Flag for Australia asked on

Adding in a Year title

Hi all, I would like to add a small detail to my site, however I am unsure where to start...

My dev site: http://d.gp.tours/?c=1 


What I would like to do is have the year separating the products, like: https://tickets.motogp.com/en/calendar/events

As you can see at the top of the page is has separated the 2021 products and the 2022 products.


Again I am unsure how I can do this, I am using ASP Classic and getting data from Access

ASP* Access 2019

Avatar of undefined
Last Comment
ste5an

8/22/2022 - Mon
ste5an

hmm, without seeing your attempts, you need to start with the overall layout in HTML/CSS/JS first. It's structure must reflect the grouping of your data. Then you can apply it in your code.

What you need to do exactly depends on the used approach and design principles.

E.g. it can be a additional sort column in your existing record set with an additional loop over the year or a separate record set with a loop over it. Or it can be just a additional sort column in your existing record and the grouping is done in JS.

p.s. posting nothing here about is not a good idea. Always include screenshots of the as-is state and sketches of the desired output. Especially as your page is currently not working (error '80020009' /home.asp, line 85).
Graeme McGilvray

ASKER
Hi Ste5an, as I have already previously mentioned, I am unsure where to start... so no attempts yet.

Both links work for me, perhaps check again?

I thought i explained it pretty clearly and gave an example page of what it would look like
ste5an

Nope, still not working...

But I wrote what you can do, which depends on your design and coding principles of the unknown, cause unseen current state of your site and its code behind.
Just apply one of those ways.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Graeme McGilvray

ASKER
Both work for me...

Unfortunately none of what you recommended made any sense, sorry
Graeme McGilvray

ASKER
I have been having a play with some code, not sure if I am on the right track:

  <%
    If Year(Prod("dep_date"))=ShowYear Then
  %>
  <tr>
    <td colspan=20 height=20><%=Year(Prod("dep_date"))%></td>
  </tr>
  <tr>
    <td colspan=20 height=20></td>
  </tr>
  <%
    ShowYear=Year(Prod("dep_date"))
    End If
  %>

Open in new window

It doesnt work, but im sure with some tweaks, it may (if im on the right track)
ste5an

This should be the structure of your unseen page right now:

Untitled.png
Right now you should have the orange and green components. Thus you need to add the blue component layer. One way to do it:

As it is ASP classic, you do this be starting at the data source. You need to simply add the year to it and sort it by year first and then by the old sort columns.
In your existing loop you add at the beginning the logic to detect a year change, a standard column value change detection. When the value changes you close the old div and open a new one with and year header.

p.s.
I have been having a play with some code, not sure if I am on the right track.
That's why I asked for screenshots and sketches. Cause you don't have an good inner vision of the design and its components and probably even its HTML/CSS representation...
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER CERTIFIED SOLUTION
Graeme McGilvray

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ste5an

Clean code is your friend:

<%
  ActiveYear = 0
  Do Until Prod.EOF
    CurrentYear = Year(Prod("dep_date"))
    If CurrentYear <> ActiveYear Then
      ActiveYear = CurrentYear
%>
  <tr><td colspan=20 height=20><b4><%=ActiveYear%> Events</b4></td></tr>
  <tr><td colspan=20 height=20></td></tr>
<%
    End If

    Prod.MoveNext
  Loop
%>

Open in new window


p.s. this is exactly one of my suggestions.