token? velocity? I don't know what I want | Community
Skip to main content
Community Manager
Mar 20, 2018 9:15 PM UTC
Solved

token? velocity? I don't know what I want

I have a marketo landing page that serves as an LMS calendar. Classes come and go, and each time we add a block of classes I add some prepared html code and drop it in the page. I would LOVE to automate a way to hide the classes that have passed, by quickly updating a token or list of past classes (potentially updating a section of html div to display:none).

I tried some js that goes off internal clocks and hides by date, but that didn't seem to work right --

I was thinking of inserting a token in the div and updating it to "display:none" as needed, but marketo seems to strip out the token when I save it.

Maybe I need a velocity script to do this in a way I haven't thought of yet (I'm not familiar with Velocity use-cases)?

Maybe someone else has done something similar? Anyone want to point me to the right rabbit hole?

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
Mar 20, 2018 11:05 PM UTC

done & done... such anticipation now...


Set up some CSS rules (I don't like to set .style directly if avoidable):

#BodyText2a { display: none !important; }

#BodyText2a[data-event-expiry-calculated="true"] { display: initial !important; }

#BodyText2a .Row[data-event-expired="true"] {  display: none; }

then

var arrayFrom = getSelection.call.bind([].slice),

    nowDate = new Date(),

    eventContainer = document.querySelector("#BodyText2a")

    eventRows = eventContainer.querySelectorAll(".Row");

arrayFrom(eventRows)

  .filter(function(eventRow){

    var eventDate = new Date(eventRow.getAttribute("data-event-datetime"));

    return eventDate < nowDate;

   })

   .forEach(function(expiredEventRow){

     expiredEventRow.setAttribute("data-event-expired","true");

   });

eventContainer.setAttribute("data-event-expiry-calculated","true");

11 replies

Nicholas_Manojl
Level 8
Mar 20, 2018 10:20 PM UTC

I think I remember doing something similar by using a Google Drive (Sheets) to populate all the info.

I then used Google Drive's publish and javascript API to display on the webpage.

Then it was a simple matter of keeping the Google Sheets up to date, which is easy whichever way you do it (manually or with formulas).

Translate
JDNelson1Author
Community Manager
Mar 20, 2018 10:32 PM UTC

hmmm, yah, I have a basic excel sheet that I put dates in and it generates a big long html code block -- interesting about the ability to publish via js api though -- might need to look into that!

Translate
Grégoire_Miche2
Level 10
Mar 20, 2018 9:49 PM UTC

HI JD,

Velocity tokens do not work in landing pages. Only in emails. Non script tokens normally do.

Send the LP URL, so that we can look at the JS.

-Greg

Translate
JDNelson1Author
Community Manager
Mar 20, 2018 9:51 PM UTC

currently no js -- just looking to find an option to do this less manually.

go.spigit.com/spigit-training-home.html

Translate
Grégoire_Miche2
Level 10
Mar 20, 2018 9:53 PM UTC

The JS is the solution I would look into.

-Greg

Translate