Hello,
How can I get the current paragraph ID in a custom module?
Thanks,
Diogo
Developer forum
E-mail notifications
Get current Paragraph ID
Diogo Lino
Posted on 08/05/2012 12:00:17
Replies
Morten Snedker
Posted on 11/05/2012 11:18:53
This post has been marked as an answer
Hi Diogo,
That depends on the context? If it is a paragraph module it's just
Regards /Snedker
That depends on the context? If it is a paragraph module it's just
using Dynamicweb; using Dynamicweb.Extensibility; namespace myShit { [AddInName("ContentModule1")] public class ContentModule1 : ContentModule { public override string GetContent() { int pID = this.ParagraphId; //TODO: Add code here return "ContentModule1: frontend output"; } } }
Regards /Snedker
Votes for this answer: 0
Diogo Lino
Posted on 11/05/2012 15:41:17
Hi,
That's good for a ContentModule class.
The problem is when trying to get it from another class. There is a hard way by checking the paragraphs in the database and find a record where the ParagraphModuleSystemName is what I'm using and the ParagraphModuleSettings has the values I'm expecting. But it's not accurate.
Regards,
Diogo
That's good for a ContentModule class.
The problem is when trying to get it from another class. There is a hard way by checking the paragraphs in the database and find a record where the ParagraphModuleSystemName is what I'm using and the ParagraphModuleSettings has the values I'm expecting. But it's not accurate.
Regards,
Diogo
Morten Bengtson
Posted on 11/05/2012 15:56:03
Hi Diogo,
What is this "another class"? You write that it is a custom module, but not a ContentModule... please explain :)
You could probably use a notification subscriber to get the current paragraph id - Dynamicweb.Notifications.Standard.Paragraph.OnBeforeRender
You can then store the paragraph id in Request.Items and then get it from there in another notification subscriber, a template extender etc.
/Morten
What is this "another class"? You write that it is a custom module, but not a ContentModule... please explain :)
You could probably use a notification subscriber to get the current paragraph id - Dynamicweb.Notifications.Standard.Paragraph.OnBeforeRender
You can then store the paragraph id in Request.Items and then get it from there in another notification subscriber, a template extender etc.
/Morten
Diogo Lino
Posted on 11/05/2012 16:19:52
In the ContentModule class I use several objects of diferent classes depending on the module properties to manage and return the content.
I can use the "this.ParagraphId" on the ContentModule class but in other classes where I already initialize them with the module properties and the pageView, I think the best solution is to initialize them also with the paragraphId as parameter or use notification subscribers as you say.
I though there could be a property on the pageView or other object that could help.
Thanks,
Diogo
I can use the "this.ParagraphId" on the ContentModule class but in other classes where I already initialize them with the module properties and the pageView, I think the best solution is to initialize them also with the paragraphId as parameter or use notification subscribers as you say.
I though there could be a property on the pageView or other object that could help.
Thanks,
Diogo
You must be logged in to post in the forum