In Answers track, in module 13, I am unable to get the CTA lable (learn more), Is the code that I attached correct?
Hi Challoju,
Youâre so close! The issue is with the subtitle.
In the screenshot above you have
subtitle: profile.c_localNonProfits ? 'In partnership with: ' + profile.c_localNonProfits : null,
This is great javascript! You are checking to see if the field has a value and then stating the action if true and false.
condition
? action if true
: action if false
The rule is looking for something a bit simpler, but we will adjust the rule checker to accommodate this level of expertise. In the meantime, I recommend removing the null check and just using the true statement assuming that c_localNonProfits will always be filled out.
The last piece is when youâre joining a list by default it will just use a comma delimiter, but to make it more human-readable youâll want the delimiter to be ", " (with a space). I took a look at your account and right now you have:
subtitle: 'In partnership with:', // The sub-header text of the card details: profile.description, // The text in the body of the card c_localNonProfits: Formatter.joinList(profile.c_localNonProfits),
This is incorrect because youâve made c_localNonProfits an attribute that is not present in your template.hbs for the card. Youâll want to make sure to remove that and only update the subtitle attribute. But you will want to use that formatter. Keep in mind that the formatter can optionally take a separator:
joinList(list, separator)
Ex:
joinList(c_textListField, ', ')
Hereâs a good unit to look at for guidance: Defining New Cards | Hitchhikers
Thanks,
Liz
I used CTA label : learn more , but I canât get it in output.
subtitle: âIn partnership with: â + Formatter.joinList(profile.c_localNonProfits,â,')
Is this how we include both âIn partnership withâ and formatter ?
For the CTA Label, you can Inspect the live preview page (right click on the page and then click Inspect) and look at the console to identify errors like this. Hereâs the error I see when I inspect your experience:
âCTA doesnât have a linkTypeâ.
This is because you are using the CTA Field Type formatter on a field that is not a CTA field.
url: Formatter.generateCTAFieldTypeLink(profile.landingPageUrl),
is incorrect. It would either need to be:
A field that is a âCTA typeâ field:
url: Formatter.generateCTAFieldTypeLink(profile.c_primaryCTA),
or
Remove the formatter and use a simple URL field:
url: profile.landingPageUrl,
For the subtitle, what you listed looks good:
subtitle: 'In partnership with: ' + Formatter.joinList(profile.c_localNonProfits,',')
Thanks!
Liz
Hey again @Liz_Frailey ,
Thanks for this previous answer that helped me much : I had the same error than Challoju with the wrong type of format for the landingPageUrl field.
The error is corrected and everything âseemsâ to be displayed correctly, but when submitting the challenge again, I still have this âAdd a new card called communitystory and update data mappingsâ error.
Here is my sandbox : https://sandbox.yext.com/s/2502750/sitesgit/r/3335/
Do you think I made another mistake ? Is this a bug ? I cannot find anything more on my side âŚ
Thanks in advance for your help.
Hi Nicolas,
Youâre so close!
It looks like you have a grammatical error:
subtitle: 'In partnership with :'
or
subtitle: 'In partnership with: '
That should do the trick
Thanks!
Liz
Damn ⌠you were right, that was the extra space before â:â (french punctuation âŚ).
I was so focused on objects, functions, fields, etc ⌠that I totally missed that simple mistake
Sorry for that, but thanks a lot for your help !!
Hi @Liz_Frailey,
Iâm running into a couple issues here as well, namely Iâm failing on âAdd and update the page for Community Storiesâ and âAdd a new card called communitystory and update data mappingsâ. Iâm really not sure what Iâve done wrong as Iâve followed all of the comments above but still canât pass, any help is appreciated! My Sandbox account is here.
Iâve attached a couple of screenshots of the code editor as well below. Any help would be appreciated!
Youâre also a wizz @Jason_Ronkin, please can you guide me if you have the time?
Hi Scott,
Did you try creating a live preview of the site? This should have highlighted that there were some issues with the code. There are a couple of things I noticed:
-
You need to update the verticalKey (in both places) in the
communitystories.json
file. The verticalKey is not the same as the API name for the entity type. The verticalKey is the unique key in the verticals object of the search configuration (which in this challenge should becommunityStories
). In Live Preview, you can notice this because the Community Stories vertical is being returned but without any styling â this is because itâs using the default of the SDK since it doesnât think youâve defined this vertical at all in the frontend (due to the invalid key)Current page:
Page you want:
-
For the communitystory card, you have an error in the subtitle. In your current code you have:
subtitle: 'In partnership with: Formatter.joinList(profile.c_localNonProfits),',
The problem is that you have the whole string encased in quotes. This would quite literally print out the string on your card: âIn partnership with: Formatter.joinList(profile.c_localNonProfits),â. However, you donât want that!Current card:
Card you want:
Make sure that you only have quotes around the hardcoded string (
In partnership with:
). You can then use " + " to connect the string with the Formatter.
Hope this helps!
Liz
Hi everyone and thanks for the tips above. Iâve checked for the above errors and gone through the challenge from scratch a few times now, but am still having an issue passing all of the requirements (esp. the final one where it asks to" Add a new card called communitystory and update data mappings". Could someone take a look and save my sanity? Thank you!
link to sandbox account: https://sandbox.yext.com/s/2507648/sites/14760/publishing/?env=staging
Hi Sarah,
The issue is with the label. The challenge is asking for just a string and youâre enclosing it in a formatter which is not necessary.
You have:
label: profile.c_primaryCTA ? "Learn More" : null, // The CTA's label
All you need is:
label: 'Learn More',
Thanks!
Liz
that worked, thank you! sweet victory!
Hi Liz,
I am having a similar problem updating CTA and subtitle section for this module. Please see my code here:
Thank you!
Hey Jenna! I would take out the part where it says " : null," in line 34 and see if that helps. I think you still have the second half of the formatter in there but the code editor may not know what to do with it since you removed the first half.