Developer forum

Forum » Development » Get page id of the module

Get page id of the module

Vilius Janulis
Reply

Hi,

I want to use this function Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl for getting friendly url for the product.

I have group id and product id, the problem is solution have multiple ecom modules for displaying groups assigned to different pages.

How to get page id , of the page that has paragraph ecom module assigned to it with settings of displaying that particular group.

I cant just take first ecom module and show it on there because the url will be different from normal click on page path url, so i need that particular one :)

 

Pseudocode

Get paragraphs with ecom module, filter them by what group ids they are showing, get page id of that page.

 

Or maybe there is better way to achieve same functionality.

 

Thank you.


Replies

 
Nicolai Høeg Pedersen
Reply

In 8.2+ on groups in Ecommerce administration you have something called primary page that serves the purpose of telling Dynamicweb on which page the group is supposed to be published. Use that feature and you have the page ID on the group.

 

By the way, consider to publish ALL your groups on the same page.

 

Why do you need to create these links if I may ask. Dynamicweb does this by it self.

 

BR Nicolai

 
Vilius Janulis
Reply

Hi Nicolai,

Thanks for a quick reply.

I am creating some specific and extended search functionality module for DW and i am looping through products there on indexing them so that is why i need the links where they are not generated. (at least product object does not have something like link/url/href) :)

We are using 8.2+ but i dont really want to tell the client how to use DW and redefine settings on many groups and modules, would be best if i could just make the few loops in code and get it as it is now.

Is there other way ? like the one i explained ? or even maybe some help with database structure for sql to get it ?

 

I would just need to loop through pages by area, paragraphs by page, module/s on page or paragraph, and settings of that module :)

 

:) thank you for the help again :)

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

The one you explains is feasable - but no easy way. On the ecom pargraphs you have a field called ParagraphModuleSettings which contains a piece of XML.

 

You can do like this:

 

For Each p As Content.Paragraph In Content.Paragraph.GetParagraphsBySql("SELECT * FROM Paragraph WHERE ParagraphModuleSystemName = 'eCom_Catalog'")
            Dim groups As String = p.ModuleProperties.Value("ProductAndGroupsSelector")
            If groups.Contains("g:" & Product.Groups(0).ID) Then
                Dim pageid As Integer = p.PageID
            End If
        Next

But be careful on performance. This statement queries the database and you do not want to do that on every page view. So you might want to cache the paragraph collection returned from this.

 

BR Nicolai

Votes for this answer: 1
 
Vilius Janulis
Reply

Thanks it helped.

Had little bit to extend it but it helped a lot :) 

Thanks

 

You must be logged in to post in the forum