+ Start a Discussion
Basant Kr VermaBasant Kr Verma 

How to pass parameters in custom Community Page

Hi Hive,

I am using Salesforce Communities (Napili template) and created a custom Community page for custom use

I want to have a page with some parameters as standard topic detail page having  (/topic/:topicId/:topicName) 

I want my page url to be like /customPage/:param1/:param2, but while creating page there is no option to set parameters.

Is there any way or work around for it ?

I already tried by setting  query parameters (/customPage?param1=value&param2=value) through javascript and read it in controller js but in this case these parameters are always there, they are not going away when we navigate to any other pages.
Best Answer chosen by Basant Kr Verma
Mohith Kumar ShrivastavaMohith Kumar Shrivastava
There are couple of ways you can navigate .Just use plain href and it works 
 
<a href="{!'/s/profile/'+usr.usr.Id}">

The other ways to naivgate is to use events available for navigation
 
<aura:attribute name="supportURL" type="string" default="your_URL"/>
<ui:button aura:id="button" buttonTitle="Contact Support" label="Contact Support" press="{!c.navigate}" class="uiButton forceCommunityAskCommunity"/>

({

navigate : function(component, event, helper) {

	    //Find the text value of the component with aura:id set to "address"
	    var address = component.get("v.supportURL");
	    var urlEvent = $A.get("e.force:navigateToURL");
	    urlEvent.setParams({
	      "url": address,
	      "isredirect" :false
	    });
	    urlEvent.fire();
	}

})

 

All Answers

Bhaswanthnaga vivek vutukuriBhaswanthnaga vivek vutukuri

Take a dummy page to send parameters and redirect to that page.

Dummy page

<apex:page controller = '{!samplecontroller}' action = '{!onLoad}'>

</apex:page>

Controller :

public class samplecontroller
{
 public samplecontroller()
{
}

public pagereference onLoad()
{
  Pagereference originalpage = Page.pagename;

   MyNewPage.getParameters().put('param1',value);

.........

return originalpage;
}
}

 

Mohith Kumar ShrivastavaMohith Kumar Shrivastava
There are couple of ways you can navigate .Just use plain href and it works 
 
<a href="{!'/s/profile/'+usr.usr.Id}">

The other ways to naivgate is to use events available for navigation
 
<aura:attribute name="supportURL" type="string" default="your_URL"/>
<ui:button aura:id="button" buttonTitle="Contact Support" label="Contact Support" press="{!c.navigate}" class="uiButton forceCommunityAskCommunity"/>

({

navigate : function(component, event, helper) {

	    //Find the text value of the component with aura:id set to "address"
	    var address = component.get("v.supportURL");
	    var urlEvent = $A.get("e.force:navigateToURL");
	    urlEvent.setParams({
	      "url": address,
	      "isredirect" :false
	    });
	    urlEvent.fire();
	}

})

 
This was selected as the best answer
Basant Kr VermaBasant Kr Verma
Thanks @Mohit
Basant Kr VermaBasant Kr Verma
I again got the same kind of requirement but still don't have this feature, so went ahead and posted an idea, please vote it so we can touch the point threshold.

https://success.salesforce.com/ideaView?id=0873A000000CLheQAG