Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • tc 41 posts 62 karma points
    Jul 24, 2012 @ 14:09
    tc
    0

    Virtual Nodes in Umbraco

    Hi There,

    I've current got a content structure similar to this:

    Content
    
    - Home
      - Articles
        - Article 1
        - Article 2
      - About
      - Contact
    
    - Users
      - User 1
        - Articles
          - Article 3
          - Article 4
      - User 2
        - Articles
          - Article 5

    In summary I have a site with a page that display links to the articles beneath it (1 and 2). I want to allow users to signup and add their own articles. So I have a registration script that creates an umbraco user, then creates the User node in the Users folder above, each user gets a folder beneath them to add their own articles. The script sets the start node of each user to there corresponding user node in the content tree.

    To illustrate, User 1 just sees:

    - User 1
      - Articles
        - Article 3
        - Article 4


    Each article belonging to a user has a url like "/Users/User 1/Articles/Article 3" however, I want to be able to create a virtual node under the Content/Articles folder so that the url is "/Articles/Article 3". Can this be done? And are virtual nodes the right approach to take?

    I also dont like the fact that the Users folder still has a navigateable URL even though it exists outside the content tree. Perhaps there is a better approach for this?

    Thanks,

     

  • Funka! 398 posts 661 karma points
    Jul 24, 2012 @ 20:39
    Funka!
    0

    Hi,

    Not sure I can help you 100%, but one concern with what you want to do is how to ensure unique URLs with such a scheme. For example, what if User 1 created an article with the exact same name as User 2, so they both create something called "Article 7".  So, when you go to "Articles/Article 7", how would you know which user to look into?

    One way to ensure unique URLs is yes, use "virtual" nodes in your one big Articles node.  Otherwise, if you could somehow ensure that the Url Name (slugs) for each article were unique, you could probably find a way not to have to "double-up" the number of nodes like this in the admin tree. Maybe you could use UrlRewrite to direct all requests under the /Articles/ path to go to a single script, which could load the appropriate content from there by analyzing the requested path.

    In regards to the /Users/ path having a navigable URL, I too wish one day there could be a way to mark a document type as "organizational only" (i.e., should not have a URL, template, nor be browsable).

    However, I think as long as you don't have a template assigned to your "Users" node---even though it has a "URL"---you won't be able to see anything as it just gives a 404 anyway. So maybe a "non-concern" for you!

    Best of luck!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Jul 25, 2012 @ 09:59
    Jeroen Breuer
    0

    You could try some url rewriting, but I don't know if that's going to be easy. This topic might also help: http://our.umbraco.org/forum/core/general/21463-General-pages-with-multiple-websites.

    Looks like there are more people who want something like this: http://our.umbraco.org/forum/core/umbraco-5-general-discussion/31163-Ghost-copying-a-node.

    Also found this: https://gist.github.com/2978346.

    Jeroen

  • tc 41 posts 62 karma points
    Jul 25, 2012 @ 10:43
    tc
    0

    Thanks very much for your responces!

    @Funka!
    Thanks for pointing out the issue with uniqueness, Its something I hadnt initially thought about, but a very important point. It seems that having the one page and passing a parameter is the way to go with this. I think im gonna have to learn a bit more about URL rewriting!  The only thing is this requires creating more controls. Each page to display an article has other user controls on it (like social sharing etc). So id need to create a control that could pull in the article and render those other controls. Which isnt to bad for a page, but if i were to expand this to include a Comments folder under each article id then have to create another page and another set of controls, so it could get a bit messy.

    I've also posted this question at StackOverflow and will be trying out suggestions there too. I'll keep this thread updated as well. One thing mentioned there is how to remove content from the navigable structure, thought you might find that useful! :)

    @Jeroen
    Thanks for those links, I shall take a look. Hooking into the publish events to create a ghost node seems like it might be a bit more expandable than the previous method, in terms of adding a comments page or other features. I think with this I would have to be careful with IDs if referencing, as I wouldnt want to reference the ghost node, but the original.

    Thanks agin for the responses, I shall put these to the test.

Please Sign in or register to post replies

Write your reply to:

Draft