Developer forum

Forum » Development » SEO Friendly URLs in own code

SEO Friendly URLs in own code


Reply
Hi,

Is there any way to take advantage of the functionality that generates SEO frieldly URLs for eCom in your own code.
I have a custom made searchresult listing that searches ecom and it would be nice to be able to use seo friendly urls in that.

Regards / Aki

Replies

 
Nicolai Høeg Pedersen
Reply
You do not have to do anything to accomplish that.

Dynamicweb parses the URLs before the response is sent. So simply make your URLs as normal: href="Default.aspx?ID=123&some=other&etc" - just make sure you start with Default.aspx?ID=123 - do not start with a / or anything.

Then rest of it is handled by the settings in management center.
 
Reply
Thanks for your reply.

I have a webusercontrol with gridviewcontrol and I set a asp:Hyperlink control with the value "Default.aspx?ID=93&ProductID..." but the url is not rewritten.

Exmaple testpage : http://www.godoc.se/Default.aspx?ss=tand&ls=Ort+%28Valfritt%29&id=251

The links "Läs mer" are not rewritten.

Regards / Aki

 
Nicolai Høeg Pedersen
Reply
Hm - just checked it out.

Controls are loaded after Dynamicweb parses the internal URL's - thats a bug we need to fix... It has bug number 4141

The only way to work around it right now is to get the final output of the page and run it through the parser:

Dim

theOutput As String = "" 'Get the output from Default.aspx output placeholder

 

 

Dim OutReplacer As New OutputReplacerIf Base.ChkBoolean(Base.GetGs("/Globalsettings/System/Url/ParseContentURL")) Then

theOutput = OutReplacer.ParseURLs(theOutput, Pageview)

 

End If
 
Reply
OK.

When could one expect this bug to be fixed?


I have this webusercontrol in a paragraph. Could you just point me in the right direction if I would like to use the workaround. How would I get the output of default.aspx and where do I put that code?

Regards / Aki
 
Nicolai Høeg Pedersen
Reply
Just made this which should work...

In your Default.aspx.vb file add this sub:

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
  Dim myStringuilder As New System.Text.StringBuilder
  Dim myStream As New System.IO.StringWriter(myStringuilder)
  Dim myHtmlWriter As New System.Web.UI.HtmlTextWriter(myStream)

  MyBase.Render(myHtmlWriter)
  Dim tmp As String = myStringuilder.ToString
  Dim OutReplacer As New OutputReplacer
  If Base.ChkBoolean(Base.GetGs("/Globalsettings/System/Url/ParseContentURL")) Then
   tmp = OutReplacer.ParseURLs(tmp, _pageview)
  End If
  writer.Write(tmp)
 End Sub



Make sure _pageview is set in Page_Load... Attached a full zipped Default.aspx.vb file...
 
Reply
Thanx for that, I'll give it a try.

/Aki
 
Reply

Hi again,

I now have the following code in the default.aspc but it still wont rewrite the links. Any ideas?



Dim _pageview As Dynamicweb.Frontend.PageView

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim pv As New Dynamicweb.Frontend.PageView()
        pv.Load()
        _pageview = pv
    End Sub
 

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)

        Dim myStringuilder As New System.Text.StringBuilder
        Dim myStream As New System.IO.StringWriter(myStringuilder)
        Dim myHtmlWriter As New System.Web.UI.HtmlTextWriter(myStream)

        MyBase.Render(myHtmlWriter)
        Dim tmp As String = myStringuilder.ToString
        Dim OutReplacer As New OutputReplacer
        If Base.ChkBoolean(Base.GetGs("/Globalsettings/System/Url/ParseContentURL")) Then
            tmp = OutReplacer.ParseURLs(tmp, _pageview)
        End If
        writer.Write(tmp)

nd Sub


 

 
Nicolai Høeg Pedersen
Reply
Your links looks like this:

href="../dev/Default.aspx?ID=93&ProductID=PROD1

They will not be parsed...
 
Reply
Examplepage : http://www.godoc.se/Default.aspx?id=25&GroupID=GROUP149

The links I am refering to is in the search result. For example:

<a id="_ctl2_search_result_view__ctl1__ctl4_link" class="resultlist_productlink" href="Default.aspx?ID=93&amp;ProductID=33b408710cce4c75b80ba748e33156" target="_top"><img id="_ctl2_search_result_view__ctl1__ctl4_product_image" class="resultlist_image" src="Files/Billeder/Logotyper/halsometern.gif" alt="Hälsometern" border="0" /></a>


/Aki
 
Nicolai Høeg Pedersen
Reply
Hi

It is because your Default.aspx has this in first line:

<%@ Page Language="vb" AutoEventWireup="false" validateRequest="false" Codebehind="Default.aspx.vb" Inherits="Dynamicweb.Admin.Load" codePage="65001"%>

You have created another assembly where your code behind is - you have to reference that in your Default.aspx
 
Reply
OK, thanks for your help, I think I got the hang of it now.

Is the "/myfolder/[ProductID/myproductid]/productpage.aspx" the way the url will always be displayed or are there any plans on getting rid of the "[ProductID/myproductid]" part in the future.

I'm asking because I know the customer will ask this. :)

/Aki
 
Nicolai Høeg Pedersen
Reply

Can not get rid of it - it would cause lots of issues then.

 
Reply
The code works just fine.

Another, more general, question regarding the URLs though;

If I set up an ecom navigation where the productgroup are generated i get URLs like:

www.mydomain.se/somefolder/myproductpage.aspx

Is there any support for getting the productgroup hierarky in the URL like :

www.mydomain.se/productgroup/subproductgroup/...

Regards / Aki


 
Nicolai Høeg Pedersen
Reply
Well - the first part of the path will always be a representation of the page structure (yellow part). You have to have pages in that order to have it work.

www.mydomain.se/page1/page2/[qs_information]/NameOfSomething.aspx

You can control the blue part though. The text comes by default from the innertext of th a-tag <a href="">NameOfSomething</a>

That can be overwritten by a title tag:
<a href="" title="ProductGroup1/Group2/Productname">NameOfSomething</a>

Then this would happen:
www.mydomain.se/page1/page2/[qs_information]/ProductGroup1/Group2/Productname.aspx
 
Reply
Thanks. That TILTE thing might be useful.

In this case I mean a URL to a product group like in this exmaplepae :

http://www.godoc.se/Default.aspx?ID=1108&Purge=True

where the links under the page "Kategorimeny" comes from ecomgroups.

So what I am trying to achieve is a URL like

www.godoc.se/Akutvård/Jourmottagning/productlistpage.aspx

where "Akutvård" och "Jourmottagning" is productgroups from ecom.

Regards / Aki

 
Reply
I tested the title thing in this page:

http://www.godoc.se/Default.aspx?ID=1108&Purge=True

I dont get thre rewrites even though I have the categoryname in the title attribute? Am I doing something wrong?

Regards / Aki
 
Nicolai Høeg Pedersen
Reply
That is because you have not enabled module urls on that website...
 
Reply
The checkbox for "Convert module URLs" is checked?
 
Nicolai Høeg Pedersen
Reply
Yes it is.... BUT

You still have <%@ Page Language="vb" AutoEventWireup="false" validateRequest="false"  Inherits="Dynamicweb.Admin.Load" codePage="65001"%> in default.aspx - so your codebehind fix is still not applied on this page... Thats why you still have URLs with ?& etc. in them.

And i do not see any updates of the GoDoc.dll which probably holds the fix?

So move your fix from development machine to production environment first...
 
Reply
I was stupid. :)  

I get the searchresult to work nicly but not the menu on the left.

Regards / Aki
 
Nicolai Høeg Pedersen
Reply
Your markup is like this:

href='default.aspx?id=25&GroupID=GROUP66'

make it like this:

a href="Default.aspx?ID=25&GroupID=GROUP66"
 
Reply
I actually changed some the markup to default instead of Default just to test if there were any difference.

But I think the reason is that I use a asp:literal to which I generate the html. If a add a asp:hyperlink the url is processed so I think I need to redo the way the markup is generated.

Thanks for your help.

/Aki
 
Nicolai Høeg Pedersen
Reply
Casing is not the important thing... But use " instead of '....

Literals do not change the text you add to them.
 
Reply
Whohoo, its finally working. :)


Discovered one feature though. When you click on a link in the sidemenu, for example http://www.godoc.se/annonser/[GroupID/GROUP228]/Akutvård.aspx then the links in the searchresult are not procecced.

And my guess is that the reason for that is because the markup is rendered like a href="../../../Default.aspx....".

And the reason for that might be that the url looks like the page Akutvård is several folders in a hierarky. Hmm?

/Aki

 

You must be logged in to post in the forum