Developer forum

Forum » Development » Issue with GetInternalPageID

Issue with GetInternalPageID

Anders Ebdrup
Anders Ebdrup
Reply

Hi Dynamicweb,

 

Were are using this function: ReplaceQueryString() to replace the current "ID" of the query string, and afterwards we need to use this function to get the right SEO-friendly url: SearchEngineFriendlyURLs.GetFriendlyUrl(), but then our ID is in the end of the url and we can have a productid in the querystring. This means that the method GetInternalPageID is not working.

 

Can GetInternalPageID be extended so it can handle that? I think the regex should be:

^Default.asp[x]*.*[?|&]ID=([0-9]*).*

 

Best regards, Anders


Replies

 
Nicolai Pedersen
Reply

Usually you would not need to GetFriendlyUrl your self... I am not glad to change that regex, because changes have a tendendcy to introduce bugs and poorer performance of the replace, and that one is used a lot... So I would prefer you made sure the method was called with a syntax it recons.

BR Nicolai

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Nicolai,

 

I understand your concern, but maybe, you can help me out, with what I are trying to achive :-)

 

We are setting up the seo-part of a shop and need to specify the hreflang for the language layers: https://moz.com/learn/seo/hreflang-tag.

To optimize the urls we need to fill in the SEO-friendly url on each page no matter the user is reading a news, buying a product or reading a regular content page, so we are using the "Languages"-loop and need to replace the "ID" of the current url:

    @foreach (var language in GetLoop("Languages"))
    {
        if (!string.IsNullOrEmpty(language.GetString("PrimaryDomain")))
        {
      var url = "https://" + language.GetString("PrimaryDomain") + "/" + Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Base.ReplaceQueryString("ID", language.GetString("PageID")));
            <link rel="alternate" hreflang='@GetHrefLang(language.GetString("Culture"))' href="@url" />
        }
    }

The issue here is that: Base.ReplaceQueryString("ID", language.GetString("PageID")) gives the new url with "ID" in the wrong location of the url, and now "GetInternalPageID" which is used by GetFriendlyUrl, is not working when displaying a e.g. product page; "Default.aspx?groupid=GROUP103&productid=3301&ID=2373"

 

Besides it will be great if the Language-loop could return the culture and the ssl-setting for the website, when more hardcoding can be avoided :-)

 

So how to solve this in a nice way instead of needing to build my own function for replacing the "ID=xxx"-part of the current url and still be able to use the built in functions in Dynamicweb?

 

Best regards, Anders

 
Nicolai Pedersen
Reply

Only option is to make a simple regex to replace that ID....

Sorry!

BR Nicolai

 
Anders Ebdrup
Anders Ebdrup
Reply

Hi Nicolai,

 

Thanks for the reply though I do not like it :-)

I still think that this is a common issue, which should be easier to implement in a website, and I hope that it in the future can be supported by the platform.

 

Best regards, Anders

 

You must be logged in to post in the forum