Comments (15)
It uses the Url property to decide on what is output, so if the item is of type Media or Content then it will get the Url from the Content property, if it is any other type it returns the Url property:
Hopefully the two above links are helpful
from our.umbraco.umbnav.
Is it because the Url property is internal.. so I can't access it to set it on umbNavItem? for a link??
from our.umbraco.umbnav.
Ah yeah probably, I did that to force the use of the Extension when rendering, I don't really want to make that public again, as I can forsee what will happen, especially on multi-lingual sites.
Open to other ideas though
from our.umbraco.umbnav.
could we use a deserialiser... I presume there already is one to take
{
"description": "/department-forms/classic-car-valuation",
"title": "testing",
"url": "/department-forms/classic-car-valuation",
"children": [],
"icon": "icon-link",
"itemType": "link"
}
this back to a umbNavItem?
from our.umbraco.umbnav.
That is done here:
https://github.com/AaronSadlerUK/Our.Umbraco.UmbNav/blob/develop/src/UmbNav.Core/ValueConverters/UmbNavV8ValueConverter.cs#L62
from our.umbraco.umbnav.
So this does work.. but feels dirty... Though it is interesting that internal properties can be deserialised to.
var json = "{\"description\": \"/department-forms/classic-car-valuation\", \"title\": \"123testing\", \"url\": \"/department-forms/classic-car-valuation\", \"children\": [], \"icon\": \"icon-link\", \"itemType\": \"link\"}";
var navitem = Newtonsoft.Json.JsonConvert.DeserializeObject<UmbNavItem>(json);
navitem.Level = item.Level;
cchildren.Insert(i + 1, navitem);
Had to manually add the level after deserialisation as that is set to be [ignored]
from the json (as you will rightly be calculating it from the nesting).
from our.umbraco.umbnav.
We also have the same issue. It would be nice to have access to the full functionality of the class.
Because there is an extension to get the Url, perhaps the setter could at least be opened up?
[JsonProperty("url")] public string Url { internal get; set; }
There are many more properties that are internal which don't have a getter/extension method. Perhaps these could just be opened up?
from our.umbraco.umbnav.
For the Url property i do not want to allow it to be used for the rendering.
The .Url() extension is what's to be used to get the link due to the additional parts.
I can make this an internal set if it will solve the problem?
As for the other properties what ones would you need access to?
And can you provide some examples so I can test the change doesn't break other parts of the system.
Thanks!
As always PRs are welcome
from our.umbraco.umbnav.
Url is the only one we need access to (not sure on what other users may need or how they have things set up).
An internal getter with a public setter should do the trick (you mentioned internal set, it should be public set). That will keep access to it going through the extension method as you intend, but still allow these injected cases to work without resorting to deserialization or reflection.
from our.umbraco.umbnav.
I will have a look at this today
from our.umbraco.umbnav.
@mistyn8 / @cibis-adrian So what I have done in PR #49 is moved all the internal classes into a new class called UmbNavInternalItem this has a property called Url which has an internal getter.
The UmbNavItem still has an internal Url property which is used by the Extension, but cannot be rendered out.
If you think this solves your issue I am happy to merge, however it will be a breaking change for your implementations.
from our.umbraco.umbnav.
@AaronSadlerUK If the line of code I mentioned was applied directly on the UmbNavItem instead of splitting it into a new class, I believe everything would have just worked without it becoming a breaking change.
from our.umbraco.umbnav.
Yes, but i do not want the Url property available on the rendering class, which it was with that line of code.
This way the extension is still the only Url, and injection can happen
from our.umbraco.umbnav.
The Url properly won't be available for rendering, it would still be internal exactly like it was before. Try it out and see. I have a local build where I've made the change I mentioned and .Url is not available as a getter so it can't be used when rendering, you have to use the .Url() extension method. But you can still do .Url = "url" for injection cases because the setter is public.
Up to you, if you want it the way you've done and as a breaking change I guess that's fine as long as it works (not sure when I'll have the time to be able to test it).
from our.umbraco.umbnav.
I had a try the way you suggested, and the Url property was visible on the class, and I can forsee issues being raised that it doesn't work when people try to use it for rendering.
So I will go with my PR in the next version, the only change required in your code should be the class name from UmbNavItem
to UmbNavInternalItem
from our.umbraco.umbnav.
Related Issues (20)
- Add option for classes to be a dropdown
- Hover should highlight the menu item
- Advanced settings remains when all settings disabled
- When there is any unpublished content, umbNav breaks: Failed to convert Meganav {ex} HOT 5
- Include Child Nodes toggle doesn't stick HOT 1
- Advanced Configuration include child nodes HOT 1
- Url not available on Link UmbNavItem HOT 6
- After the update UmbNav doesn't work HOT 5
- Sub navigation Not Displaying HOT 12
- trying to add multiple sub menu items to top Nav HOT 1
- Retrieve value from IVirtualPageController (?) does not work HOT 12
- Label item type does not render when at the top level HOT 8
- When ItemType == Link, cannot get Url HOT 13
- Non Content Link Url not accessiable in Views HOT 1
- Member Visibility isn't working HOT 4
- Clone/Fork repo - running test projects fails with `Unable to satisfy conflicting requests` dependency issue HOT 3
- Ability to show active class on a child page HOT 1
- Umbraco V13 support HOT 1
- What is the difference between versions? HOT 2
- Unhandled exception on new install of .Web to Umbraco 13.0.1 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from our.umbraco.umbnav.