• raghu narayana
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
I have written a Lightning Component of Modal Popup to show popup in home page of public community website , it will be shown whenever user visits the website. 

My requirement is here is popup window should show only once when the user visits the website for the first time.
But the issue is , whenever the user visits to the website or other sub pages of the site and come back to the home page, again the popup appears. 
In this we want to set the modal popup should be shown only for the first time when the users visit the site , 
as in the popup we are just making sure the user is aware of Privacy policy .
Once, the user clicks on OK, everytime the Privacy policy popup should not get open when the user visits the site and home page.

code
popup.cmp

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <aura:handler  name="init" value="{!this}" action="{!c.showInfoToast}"/>   
    <div>
        <lightning:button 
                          variant="brand"
                          onclick="{!c.showInfoToast}"
                          >
        </lightning:button>
        
    </div>
</aura:component>

popupcontroller.js

({
    
   
    showInfoToast : function(component, event, helper) {
        var toastEvent = $A.get("e.force:showToast");
        toastEvent.setParams({
            title : 'Info ',
            
            messageTemplate: 'This website use cookies. For details see  {1} ',
            messageTemplateData: ['Salesforce', {
                url: 'www.privacypolicy.com'',
                label: 'Privacy Policy',
            }],
            duration:' 5000',
            key: 'info_alt',
            type: 'info',
            mode: 'sticky'
        });
        toastEvent.fire();
    },
    
    doInit: function(component, event, helper) { 
 var temperorySession = localStorage.getItem('tempSession');
  if(temperorySession == '1')
        {  
      console.log('===== in If');
            component.set("v.isModalOpen", false);
  }
        else
        {
      console.log('===== in else');
      component.set("v.isModalOpen", true);
  }
   localStorage.setItem('tempSession', '1');
 }
    
    
})
 
Can we get this functionality by creating lightning compnent? Note: The lightning component has to load immediately when the user enters the communty home page. 
I am not able to verify the final step -8. I am getting the error as follows.Did anyone face the same issue?
User-added image
Can we get this functionality by creating lightning compnent? Note: The lightning component has to load immediately when the user enters the communty home page. 
Challenge Not yet complete... here's what's wrong: 
The getBoats() method isn't working properly. Define getBoats() In the BoatSearchResults Apex controller to accept an optional boatTypeId and return all boats if no boatTypeId is passed, and a filtered list of boats if a boatTypeId is passed.

getting this error