Copied to clipboard

Flag this post as spam?

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


  • James 251 posts 1169 karma points
    Jul 10, 2014 @ 14:06
    James
    0

    Creating Dynamic Content

    Hello all :)

     

    Wasn't sure what to title this.

     

    I have been going through the tutorials and I have installed a basic starter site for umbraco. You can see on the home page that it has 4 sections that link to 4 seperate pages:

    1. Getting Started
    2. Go Further
    3. Installing Modules
    4. About
    Is there any way to create another one of these (automatically) when you add a new page?
    I am looking for the best way to structure a portfolio page with portfolio items that are created when a user adds a new portfolio item.
    So:
    User creates portfolio item with text, video and images. An extra item is added to the list of portfolio items on the portfolio page. Then when a user browses the portfolio page they can click an item and it displays a bigger page with all of the content.
    Is this something that can be done automatically or will I have to create a portfolio item thumbnail template and a portfolio item page template.
    Hope i have explained that well enough for someone to help me :)

  • Dan 1288 posts 3921 karma points c-trib
    Jul 10, 2014 @ 15:16
    Dan
    0

    Hi James,

    With Umbraco you need to build your templates, pretty much like you would if it was a static site, but then the bits that are dynamic (like navigation or grids of thumbnails which link to child pages in your case, etc) can be pulled out into distinct blocks of code, called Partials.  So you'll need to build a template for your main portfolio page and a template for the portfolio item page, but your thumbnails will be a partial.  

    In much the same way as how the navigation works on the starter site, you can generate your portfolio item thumbnails directly from the nodes in the Umbraco content tree - so when an Umbraco editor adds a new node in the tree (a new portfolio item under the portfolio node) it can create the thumbnail for them on the portfolio page of the website which will link through to that portfolio item page.

    To point you in the right direction on this, try adding a new node to the content tree of the starter site by right clicking the home node and selecting 'Create' then filling in all the page details and hitting 'Save & publish'.  You should see that a new navigation item has now been created on the website and it automatically links to this new page.  The logic for the navigation (which will be the same thing you'll create for your portfolio thumnails, as they are, in essence, navigation) i.e. the Partial, can be found in the Settings section in Umbraco, under 'Partial Views' - the file is called 'umbTopNavigation'.  Click on that and you'll see the code which pulls the child pages out of the content tree and displays them as navigation.  You should also see where this Partial is included in the template, which is in Settings > Templates > Layout; the line of code which renders the Partial is on line 41.

    I hope this helps. 

  • James 251 posts 1169 karma points
    Jul 10, 2014 @ 15:29
    James
    0

    Thanks very much for your response. Very helpful.

    I have gone through and had a look.

    Inside the umbTopNavigation partial view.

    Inside the foreach statement, where does "menuItem" come from? Is this pre written umbraco code that i can use in my projects or is this something that was written specifically for this template?

    Kind regards.

  • Dan 1288 posts 3921 karma points c-trib
    Jul 10, 2014 @ 15:36
    Dan
    0

    Sure.  Actually, and this is pointing out the obvious (not meaning to be rude I promise :) ) but the comments in that template are pretty good so definitely worth reading.  Starting at the top it's creating a variable to get the homepage node of the site.  It's then creating the variable `menuItems` which it's saying should be all children of the homepage which aren't marked as hidden (there's a checkbox on those pages in the content section).

    The loop then loops through each item in menuItems and pulls out some properties from it, such as the Url and the Name (which is the node name in the Umbraco tree, and obviously what makes up the name of the item in the site navigation).

  • James 251 posts 1169 karma points
    Jul 10, 2014 @ 15:38
    James
    1

    I think ill stop posting on the forums for a while and actually use my brain :)

    Thanks for your input I will be back soon with some real questions i'm sure :)

    Thanks for being very helpful!

  • James 251 posts 1169 karma points
    Jul 10, 2014 @ 15:40
    James
    0

    Actually one last noob question :)

    Why is it that when i open my project in Visual studio i cant really see anything to edit? Most of the folders int he solution explorer show dummy text files.

    Can i edit my partial views from visual studio?

    Im not sure there would be any real point but im curious.

  • Dan 1288 posts 3921 karma points c-trib
    Jul 10, 2014 @ 15:40
    Dan
    100

    Haha, no worries at all :)

    Regarding Visual Studio, I'm not sure how you've set that up.  I think when you set up a blank project it can create 'placeholder' dummy files all over the place - there must be an easy way to prevent that, but if not just search for anything starting with 'dummy' and delete.  You don't need that stuff.

    In a typical Umbraco Visual Studio solution (e.g. if you installed via NuGet) you'd have a folder called 'Views' which is where the template files are, and one within that called 'Partials' which is where your partials are.  You can then merrily edit away.  There are various ways of getting intellisense on your Umbraco models but that's a whole other subject.  I tend to work in either Visual Studio or if it's a mega quick/light implementation WebMatrix as the code editors are waaaaaaay better than the ones in the Umbraco back-office, which are great for a quick fix but ultimately aren't geared for proper dev.

    If you're having difficulty setting up your solution in Visual Studio maybe open up another thread.  It'd be worth getting right as it'll save you time in the long run.

  • James 251 posts 1169 karma points
    Jul 10, 2014 @ 15:51
    James
    0

    Thanks very much for your informative replies to my questions :)

     

    It helps if i "show hidden files" too :) as all the view files are hidden.

     

    Im happy i can edit in visual studio now :)

     

    Thanks again for the responses.

     

    Kind regards.

     

Please Sign in or register to post replies

Write your reply to:

Draft