cast01
cast01

Reputation: 663

Umbraco Virtual Nodes

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,

Upvotes: 4

Views: 917

Answers (1)

marapet
marapet

Reputation: 56466

This can be done (of course - it's Umbraco).

Here's how you could go about it:

  • umbracoHideTopLevelNodeFromPath set to true in the web.config, and slightly change your structure:

    Site
      Home
      AllArticles
        Article 1
        Article 2
      About
      Contact
    Users
      User 1
        Articles
          Article 3
      User 2
      ...
    
  • Use Manage hostnames on Site to define the site's hostname (right-click on the node).

  • Configure a redirect from Site to Home (there is a package for redirects)
  • The Users section should be completely out of the usually navigatable node structure and therefore not be visible.
  • Document type AllArticles uses a template which displays all articles of all users by default (query by document type), and when called with a parameter (or prettier when using url rewriting) identifying uniquely the article, shows the article.
    • Of course different users may use the same name for their articles, so you won't be able to simply use the article's name to identify it.

Upvotes: 1

Related Questions