How to set URL of a content page to point to the home page
Hi,
I'm fairly new to Umbraco and in the process of creating my first site. I'm using c# to create a model of my nav structure then using razor to loop through the model to render the nav items. It's all working fine.
However, I have a "Services" nav item under "Home" (which has several children) for which a want the href URL to remain as a '#' i.e. I don't want to create a Services page - I simply want the visitor to be able to select the sub-menu items.
I have a doc type of Services which uses a template called "Services".
How can I configure the URL for the "Services" page so the href is set to a '#'?
Thanks for the prompt response. I had the same idea (and as you can see from the code have tried) - but I also wondered if there is a more elegant, back-end solution I could use rather than hard coding something.
I try setting @item.Link.Url = "/"; - but the datatype for attribute Link is 'Link' - and, as I'm trying to set it to a string value, the following error is generated:
"Invalid expression term '='"
So, I guess my question is - what syntax should I us to programmatically set the href value for my Services page to '#'?
How to set URL of a content page to point to the home page
Hi,
I'm fairly new to Umbraco and in the process of creating my first site. I'm using c# to create a model of my nav structure then using razor to loop through the model to render the nav items. It's all working fine.
However, I have a "Services" nav item under "Home" (which has several children) for which a want the href URL to remain as a '#' i.e. I don't want to create a Services page - I simply want the visitor to be able to select the sub-menu items.
I have a doc type of Services which uses a template called "Services".
How can I configure the URL for the "Services" page so the href is set to a '#'?
Hi Simon
You have to detect in code where you are on Services page and insert # in place where should be url.
Can you share code of the nav? We will find out how to fix it.
Thanks,
Alex
Hi Alex,
Thanks for the prompt response. I had the same idea (and as you can see from the code have tried) - but I also wondered if there is a more elegant, back-end solution I could use rather than hard coding something.
I try setting @item.Link.Url = "/"; - but the datatype for attribute Link is 'Link' - and, as I'm trying to set it to a string value, the following error is generated:
So, I guess my question is - what syntax should I us to programmatically set the href value for my Services page to '#'?
Here is the code:
Simon,
I would like to use this code:
Do not set value to item.Link.Url, just use it and use another variable instead.
Thanks,
Alex
Alex,
That worked ;-) - though I did have to take the '@' of the assignment statement - so it reads:
linkUrl = "#";
Many thanks for your help.
Simon.
You are welcome, Simon, mark topic as solved and have a great day.
/Alex
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.