I think Request.ApplicationPath; will give me the request url path or? and not the root path of umbraco (i cant use static value here because it can be changed via content section "siteName").
I need a script like:
If URL (browser URL) = root.Node() than do something
You could try checking the HTTP_REFERER ServerVariable to see if it matches the "root" node's URL.
Or...do you want it to fire if the user visits /en/home.aspx directly also? Because then you could just use Daniel's code but compare against the node's parent also
What do you mean by root node, just that it's a level 1 node?
In that case you could test the current node's level, if it's 1 it's a root node right? And if it's 2 you could check the umbracoRedirect on it's parent.
Node currentNode = Node.GetCurrent(); Node parentNode = new Node(currentNode.ParentId);
Gotcha, I think the above would work then. If current node's level is 1 then it's root. Or if level is 2, then check the parent node's (level 1) umbracoRedirect and if it matches the current page, it's a "root".
Look if opened site is a root site
Hello,
in my own c# code i want to write an if statement.
Is it possible to get the information if the url the user has tried to opend is a root path in umbraco?
Can someone please help?
Thanks
is there any way how i can get root path with umbraco.library from c# code?
i think you can use this : Request.ApplicationPath;
take a look on this document : http://www.cambiaresearch.com/articles/53/how-do-i-get-paths-and-url-fragments-from-the-httprequest-object
Hi gilad,
I think Request.ApplicationPath; will give me the request url path or? and not the root path of umbraco (i cant use static value here because it can be changed via content section "siteName").
I need a script like:
If URL (browser URL) = root.Node() than do something
Check the current nodes NiceUrl and compare to the root nodes NiceUrl.
psuedo example:
or just compare the ids:
Thanks Daniel,
Will this also work if root node has a redirect and the user opens the redirected page via browser url?
So the opened site is the redirected site from root node
Thanks
Don't think so.. if you browse directly to the "redireded" page, it won't have a handle to the node that would have redirected it normally.
You could use the url to look up nodes that are redirecting to it.. if there is only one, then you have it.
What method are you using to redirect?
Hi Daniel,
I am using the "umbracoRedirect" method.
The problem is that i dont want to use a fix path in my script because the sitename is dynamic and can change
So the user open www.domain.com/en in browser and is forwarded to www.domain.com/en/home.aspx - there i have to look if it is a root redirect.
Is this possible?
Thanks
Hi Daniel,
Any idea?
You could try checking the HTTP_REFERER ServerVariable to see if it matches the "root" node's URL.
Or...do you want it to fire if the user visits /en/home.aspx directly also? Because then you could just use Daniel's code but compare against the node's parent also
Hi Tom,
What i want to do is :
Look if the opened URL is the root node or a redirect from the root node.
But it should not be shown if url is www.domain.com/products/test.aspx
Thanks for your help
Do you already know the ID of this "root node"?
If so you could use Daniel's code but also compare the value of the umbracoRedirect
hi tom
i dont want to use a static root node. i want to get it dynamically. Is this possible? So rootnode.id should automatically be the root node
If not how can i get it?
What do you mean by root node, just that it's a level 1 node?
In that case you could test the current node's level, if it's 1 it's a root node right? And if it's 2 you could check the umbracoRedirect on it's parent.
oh great thanks tom,
Yes root is top level. There are two root nodes. My structure is like this
- en (redirect to home)
- home
- Products
- Test1
- Test2
- de (redirect to startseite)
- startseite
- Products
- Test1
- Test2
And i want to check if the url the user has opend is the root.
So it should return true if:
domain.com - domain.com/en - domain.com/en/home.aspx
or domain.com/de - domain.com/de/startseite.de
is opened and false if
domain.com/en/products/ is opend
Thanks for all
Gotcha, I think the above would work then. If current node's level is 1 then it's root. Or if level is 2, then check the parent node's (level 1) umbracoRedirect and if it matches the current page, it's a "root".
thanks tom,
i will try it on monday because tomorrow is a bank holiday in germany
But one question will it know rootNode.ID? or where can i get it from?
thanks for all
Hi Tom. If I try your script rootNode is not known. Can you please tell me how to get it?
Thanks
Sorry, it should be currentNode.Id.ToString() instead of rootNode, since we are checking if the parent (level 1) has a redirect to the current page.
now its working. Thanks a lot
Really great support!
is working on a reply...