we would like to implement an extension which generates URLs from a database field. (Hopefully this is the right place to post this question... Sorry in advance if not...)
Example : News
We would like to have a link like this:
www.myhost.com/News/title_of_news.aspx
Where /News would be the news list and title_of_news.aspx would be the same detail view page.
Maybe this can also be done in the configs - any hint is highly welcome...
exactly at this point the problem has it's root...
The news are feed from a different DB. The listing page reads the db (an UserControl) and redirect with paramter to the detail view page. I would like to have a nice URL instead of the ID. The news are not kept in the umbraco DB...
I'm looking for some kind of url rewriting like typo3 does - it takes the news title and creates the url thereof.
But at the moment I can't find a hook or method, where I can hook in and create an nice url which is then translated to the right news ID on the news-detail page.
I hope this explanation makes it more clear than my first request...
On the news page you then have a usercontrol that looks for the id, - if no id: connect to external db and list news items - if id provided: get news item from external db and display
you are absolutely right in your assumption. Obviously you would have to identify the news items by name rather than id if you don't want to put the id into the link as well like
/news/####-my_funky_news_title.aspx (see the link displayed for this forum post!) or /news/my_funky_news_title_####.aspx or /news/my_funky_news_title.aspx?id=#### (in which case you can just ignore the name, however is probably not at all what you want)
URL Rewriting
Hi there
we would like to implement an extension which generates URLs from a database field. (Hopefully this is the right place to post this question... Sorry in advance if not...)
Example : News
We would like to have a link like this:
www.myhost.com/News/title_of_news.aspx
Where /News would be the news list and title_of_news.aspx would be the same detail view page.
Maybe this can also be done in the configs - any hint is highly welcome...
Best Regards
Martin
Soo... What is you question exactly?
Can't you just create a node called 'News' with news items underneath it?
Then you automatically get URL's like /News/Some-news-message.aspx
Hi
exactly at this point the problem has it's root...
The news are feed from a different DB. The listing page reads the db (an UserControl) and redirect with paramter to the detail view page.
I would like to have a nice URL instead of the ID. The news are not kept in the umbraco DB...
I'm looking for some kind of url rewriting like typo3 does - it takes the news title and creates the url thereof.
But at the moment I can't find a hook or method, where I can hook in and create an nice url which is then translated to the right news ID on the news-detail page.
I hope this explanation makes it more clear than my first request...
Hi Martin,
you can create a custom rewrite rule in the UrlRewriting.config file like so:
On the news page you then have a usercontrol that looks for the id,
- if no id: connect to external db and list news items
- if id provided: get news item from external db and display
Hope that is what you are looking for,
Sascha
almost - but it looks close to what I'm looking for.
To put it right:
you suggest creatîng a link in the News-List module like so: news/my_funky_news_title.aspx
The deails page would then receive an url param called id which holds "my_funky_news_title" - right?
this would then look like this: news/detailpage.aspx?id=my_funky_news_title
Do I understand this correctly?
if this is your suggestion, then I guess this is what I'm looking for :-)
Martin
Hi Martin,
you are absolutely right in your assumption. Obviously you would have to identify the news items by name rather than id if you don't want to put the id into the link as well like
/news/####-my_funky_news_title.aspx (see the link displayed for this forum post!) or
/news/my_funky_news_title_####.aspx or
/news/my_funky_news_title.aspx?id=#### (in which case you can just ignore the name, however is probably not at all what you want)
Cheers,
Sascha
Thanks alot!
this is the perfect solution for my needs!
the first 2 suggestions
"/news/####-my_funky_news_title.aspx (see the link displayed for this forum post!) or
/news/my_funky_news_title_####.aspx or"
are perfect and would ease my life - but I'm a dummy in RegEx - could you help me out with this one?
How do the RegEx need to look like?
Thanks in Advance
Martin
Hi Martin,
give this a try:
<add name="newsredirect"
Sascha
Perfect!
thanks alot! Works like a charm!
Hello.
i am new to umbraco. i have one used car exporter website based on umbraco.
my url is like this "http://www.sitename.com/make=21&c=na&name=honda
i would like to rewrite this url, but i am not getting the rewritten url in address bar. its still showing the old url.
i have created the link like this:
<
li><a href='/stocksearch.aspx?make=21&c=na&name=toyota'>TOYOTA</a></li>currently i am writing the rule in urlrewriting.config like this:
<
i have turned on these two bits in web.config.
add name="makenamerewrite" virtualUrl="^~/(.*)/(.*)/(.*).aspx" writeUrlParameter="ExcludeFromClientQueryString" destinationUrl="~/stocksearch.aspx?make=$1&c=$2&name=$3" ignoreCase="true" />umbracoHideTopLevelNodeFromPath=true
umbracoUseDirectoryUrls=true;
i have also done the wildcard mapping in IIS.
Kindly help me asap.
Thanks alot
is working on a reply...