My lightning component -
<aura:component access="GLOBAL" implements="forceCommunity:availableForAllPageTypes,force:appHostable">
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<!-- <ltng:require scripts="/resource/jqueryminjs" afterScriptsLoaded="{!c.doInit}"/> -->
<aura:attribute name="articleId" type="String" access="global" />
<forceChatter:feed type="Record" subjectId="{!v.articleId}" />
<p><b>{!v.articleId}</b></p>
</aura:component>
and client controller -
({
doInit : function(component, event, helper) {
var currentArticleUrl = window.location.href;
var articleId = helper.getURLParameter('id');
if (articleId != null) {
console.log('article Id -->', articleId );
component.set("v.articleId", articleId);
}
}
})
Helper code -
({
getURLParameter : function(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
})
Article Id is coming from url parameter. So url can be something like-
https://domain.lightning.force.com/c/TestKnowledgeArticleApplication.app?id=ka07E0000004IVGQA2
I checked that article Id is coming properly on component
tag and client side controller, but the tag even though using the same attribute does not get the value. I am using this in Napili template component.