Developer forum

Forum » Templates » Userfriendly URL and items

Userfriendly URL and items

Sten Hougaard
Reply

Hi,

I would like to know how to get userfriendly URL in an item based website.

For instance I have the URL: http://wall.martin.com/da-DK/Wall-Of-Dedication.aspx?open=68
 

Which I would like to become: http://wall.martin.com/da-DK/Wall-Of-Dedication/Louis-Oliver.aspx

"Louis Oliver" is the page name.

I do not understand how, if possible, to setup that in Management Center.


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Sten,

Did you turn on "Customized URLs" in the settings of the item type?

Imar

 
Sten Hougaard
Reply

Hi Imar,

Good point! :-) However it does not seem to affect the URL.

/Sten

 
Nicolai Høeg Pedersen
Reply

Hi Sten

Consider using page based items when URLs and meta data are important. You then get all the possibilities of controlling URLs, avoiding DC and all that crap.

For getting item detail URLs to work:

  1. In MC, enable item URLs
  2. On the item type definition, settings, enable "create customized" urls. You need to do this for each item type that needs the URLs

Your querystring parameter does not look like an item detail, it should be something like ID=itemtype:id.

 
Sten Hougaard
Reply

Hi Nicolai,

Just to be sure that I get it right:

Following your directions (we do use page for items) I should be able to view an item using:

/da-DK/Wall-Of-Dedication.aspx?id=Story:74

The 74 is the "page id" or the ITEM id?


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964

 

 
Nicolai Høeg Pedersen
Reply

It is the pageid

But why are you creating the links your self? The item publisher have a tag with the link info...

Nicolai

 
Sten Hougaard
Reply

The itempublisher is too slow, so we use SQL to fetch, filter and sort the items.

At one scenarie Dynamicweb itempublisher took 7000 ms to find 12 items, changed it to SQL and it took 300 ms!

Also the filter on itempublisher is simply not powerfull and flexible enough for us.

I should be able to use the API to give a user friendly URL, right?

http://developer.dynamicweb-cms.com/api8/#Dynamicweb~Dynamicweb.Frontend.SearchEngineFriendlyURLs~GetFriendlyUrl(String).html

GetFriendlyUrl("/da-DK/Wall-Of-Dedication.aspx?id=Story:74")

 

Would that return the userfriendly URL?

/Sten

 

 
Sten Hougaard
Reply

I have just updated my Razor code, where I have a reader which reads items:

// SEO URL
string ItemPageID = reader["PageID"].ToString().Trim();
string SEOURL = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(ItemPageID);

And that generates a userfriendly URL :-) Like this:

/da-DK/Louis-Oliver.aspx

That is great :-)

/Sten

 
Nicolai Høeg Pedersen
Reply

You can call that method.

But don't. Dynamicweb does it for you.

 
Nicolai Høeg Pedersen
Reply

Sten, would like some more info on the slow item publisher... Can you mail me the item type(s) and some info on the amount of data?

 
Sten Hougaard
Reply

Nicolai today I cannot find time to collect that information, but I will try to remember to send it at a later time.

In short, something like this: 1500 items, filtered by 3 values.


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

E: sho@1stweb.dk
M: 29850818
A: København/Aarhus . W: www.1stweb.dk
@: netsi1964

 
Nicolai Høeg Pedersen
Reply

Thanks

We are testing it now!

 
Nicolai Høeg Pedersen
Reply

Hi Sten

We see the issue with performance on long item lists. It is due to continuous loading of field settings - that is a bug.

It is registered with TFS#15747 shceduled for 8.5.0.2

BR Nicolai

 
Sten Hougaard
Reply

Thanks.

I am happy to share small issues, and even happier when some action is taken :-)

However we need to be able to do more advanced filtering for us to be able to shift back to Item Publisher (IP):

a) Should be possible to choose logical condition, like "AND", "OR"...

b) Option to let the filter be conditioned on a parameter for the filter has been posted, like "IfNotEmpty()". For instance if you have an option to filter on 3 values, and only two of them has been posted. Then the 3. should not be in the WHERE.

I understand that it may be complex to implement, but you are on the right path and lets make IP even better. Perhaps by adapting things from Datalist, where an option to enter your own SQL could be implemented.

/Sten

 
Mikkel Ricky
Reply

There is a slightly hidden feature built into the item publisher in Dynamicweb 8.5: Query string filtering.

If you add Name=M* to the query string, then only items where Name starts with M will be shown. Filters can be combined (using and), i.e.

Name=M*&Birthdate=2000-01-01&DateAndTime.op=gt

will show items where Name starts with M and Birthdate if after (gt, greater than) 2000-01-01.

Filters can be used in @RenderItemList as well:

@RenderItemList(new {
  ItemType = "Page",
  ListSourceType = "Area",
  ListSourceArea = 1,
  ItemFieldsList = "*",
  ListTemplate = "ItemPublisher/List/List.cshtml",
  ListPageSize = 10,
  // Filter = @"Number is between 2 and 4",
  Filter = "Name does not start with 'F' and Name contains 'a'"
})

and you can compute filters using expressions:

  Filter = "DateAndTime is after "+DateTime.Now.ToString("yyyy-MM-dd")

Best regards,
Mikkel

 
Christian Rud Skovgaard
Reply

Hi Sten,

 

We managed to improve the performance when displaying many items with the item publisher. It will still be quite slow when displaying more than 1000 items without paging, but this should also be a very rare scenario (this will probably require a display cache). The improvements are checked in to the 8.5.1 release.

 

Kind regards

Christian 

 
Sten Hougaard
Reply

Hi,

If I generate a userfriendly URL like "/da-DK/Louis-Oliver.aspx" from itemid = 69, is the any part of the Dynamicweb API which can translate that into infomation back into an item id (69) ?

So that when someone tries to view the page with "/da-DK/Louis-Oliver.aspx" my razor code would get the itemid 69.

Is that possible?


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

 
Mikkel Ricky
Reply

If your page is item based then you already have access to the item fields and system fields (like item id) – use @TemplateTags("Item.") to see them all. Dynamicweb takes care of getting the right content based on the current request (url).

Best regards,
Mikkel

 

 
Sten Hougaard
Reply

Hi,

I have now upgraded to 8.5.1 but still the *details view* of a single item does not seem to be converted into a userfriendly URL.

Consider this:

You have a item where the name of the item should be used in the userfriendly url.
If I use item publisher with the userfriendly url activated in the management center.
On the item I have configered the item to generate userfriendly URL.

If I click on a link to see a single item I get: /da-DK/Wall-Of-Dedication.aspx?itemid=Story:68

Where I would have expected a more userfriendly URL.

Is that a bug?

If I use the API to get a userfriendly URL using the item id I do get a more friendly URL like:
/da-DK/MyName.aspx 
(if name field is "My Name").

however *that* link is to the item it self, I need a link for a details view on the item publisher page.
Like we have in eCom: /products/chairs/largeChair.aspx
For a chair called "largechair" in the group chairs on the page products.


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

 

 
Mikkel Ricky
Reply

Take a look at the section "Customized URLs" in the items manual.

Best regards,
Mikkel

 
Sten Hougaard
Reply

Hi Mikkel,

I have done the following:

  1. Activate "Brugerdefinerede URL´er" on the itemtype
  2. Userfriendly URL: "Item typer (itemId): Genererer urler for item typer i formatet /SystemNavn(.aspx)"
  3. Each item have a "name" field and on each item Dynamicweb backend says "Bruges som titel", so that should be fine too

That is what the manual says, and none of those informations are new to me. Still it does not solve the basic problem, where the URL is not converted but where an ID is included in the URL.

I expect that itempublisher should be able to show "details" on each item, and not linking to another page to show a single item. Just like in eCommerce where you can show groups and products on the same page. 

Please note that the above information is related to an internal 8.5.1 solution - not the live solution.


Med venlig hilsen/Best regards,

Sten Hougaard
Webudvikler

 
Mikkel Ricky
Reply

How are you using the urls in your item publisher template?

The item publisher itself does not render customized urls in @ItemPublisher:Item.DetailsUrl and @ItemPublisher:Item.Url, but when using the urls in content like this

<a href="@item.GetValue("ItemPublisher:Item.DetailsUrl")">Details</a>

the output replacer converts them to customized urls.

Furthermore, Dynamicweb.Frontend.SearchEngineFriendlyURLs.getSearchFriendlyUrl does not work with urls starting with a slash (like url genereted by the item publisher), and you have to call it like this

Dynamicweb.Frontend.SearchEngineFriendlyURLs.getSearchFriendlyUrl(item.GetString("ItemPublisher:Item.DetailsUrl").TrimStart('/'))

to get the customized url.

I'm not sure if this are bugs or intented behaviour, but I'll find out. 

 

Best regards,
Mikkel

 

You must be logged in to post in the forum