First of all wishing You a happy new year and thanking you for maintaining this great package.
I have created a static cache of the umbraco site which uses 301 url tracker.
On the static copy of the site, I would like to create the pseudo (redirect) pages for the Custom URL entries that users have created with 301 url tracker.
My question is how can I go about retrieving the list of Custom URL entries created within 301 url tracker, within code (Razor/Event-API)?
Would greatly appreciate if you can share your thoughts.
I realised one needs to add UrlTrackerRepository after Repositories (looking at other threads, no access to VS)
So this is what I come up with to get all the (only) Custom URLs in Razor:
Not sure if its complete... hopefully will help others looking for the same.
var x = InfoCaster.Umbraco.UrlTracker.Repositories.UrlTrackerRepository.GetUrlTrackerEntries(100, 1, "", false, false, false, true, false, "", false);
foreach (var entry in x ){
<p>Entry with id @entry.Id</ p >
<p>OldUrl: @entry.OldUrl</p>
<p>RedirectUrl: @entry.RedirectUrl</p>
<p>CalculatedOldUrl:@entry.CalculatedOldUrl</p>
<p>CalculatedRedirectUrl: @entry.CalculatedRedirectUrl</p>
<hr/>
}
Retrieving list of Custom URL entries from Code
First of all wishing You a happy new year and thanking you for maintaining this great package.
I have created a static cache of the umbraco site which uses 301 url tracker.
On the static copy of the site, I would like to create the pseudo (redirect) pages for the Custom URL entries that users have created with 301 url tracker.
My question is how can I go about retrieving the list of Custom URL entries created within 301 url tracker, within code (Razor/Event-API)?
Would greatly appreciate if you can share your thoughts.
You can use
InfoCaster.Umbraco.UrlTracker.Repositories.GetUrlTrackerEntries(int? maximumRows, int? startRowIndex, string sortExpression = "", bool _404 = false, bool include410Gone = false, bool showAutoEntries = true, bool showCustomEntries = true, bool showRegexEntries = true, string keyword = "", bool onlyForcedRedirects = false)
Just leave
showCustomEntries
set to true and the other arguments according to your needs.Thanks for the pointer.
I realised one needs to add UrlTrackerRepository after Repositories (looking at other threads, no access to VS)
So this is what I come up with to get all the (only) Custom URLs in Razor: Not sure if its complete... hopefully will help others looking for the same.
Ah I'm sorry, forgot to include the class name indeed. AFAIK you don't need to set
maximumRows
andstartRowIndex
, so you'll get:var x = InfoCaster.Umbraco.UrlTracker.Repositories.UrlTrackerRepository.GetUrlTrackerEntries(null, null, "", false, false, false, true, false, "", false);
Many thanks for clarifying!
changed the first and 2nd param to null to get all.
For Custom Urls concerned, is it safe to assume the attribs to read, to replicate the manual redirect, are the following fields?
Yeah I think so :-)
Cool! Many thanks again!
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.