4

How to use a Visualforce page as a Component Lightning Community page?

Hello , I have a button in Lightning component and on click of it I want to redirect to a VF page. I am able to do that in App view , But when I drag the component into the community builder , it gives 404 error. and it does not work the way it should

Component Code


<input class="btnCss" type="button" name='button' value="Continue" onclick="{!c.getNextPage}"/>
    </p>

Controller Code window.open("MyURL");

Issue is not with href or window.open , Issue is with community builder not allowing to open external pages .

Any suggestions/solutions

1
  • I believe to access your vf from community builder you need to exposed that vf page as site, then give the url of that site. Community runs on different domain Oct 7, 2017 at 6:25

1 Answer 1

0

Have you tried using force:navigateToURL . This is give exactly what you are trying to achieve.

navigate : function(component, event, helper) {

//Find the text value of the component with aura:id set to "address"
var address = component.find("address").get("v.value");

var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
  "url": 'https://www.google.com/maps/place/' + address
});
urlEvent.fire();
}

https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/ref_force_navigateToURL.htm

2
  • This only works in one.app container. Do you know a way to redirect to VisualForce page from Lightning Application that is embedded in VisualForce page too? Mar 27, 2017 at 10:59
  • You can always use, Javascript redirect window.parent.location ='/006'; Mar 27, 2017 at 12:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .