Copied to clipboard

Flag this post as spam?

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


  • Mario 11 posts 31 karma points
    Feb 09, 2010 @ 20:45
    Mario
    0

    Create list of links with different class inside the li tag

    Hi, this is my first post about umbraco. i'm making a site and i don't know how build an ul li list with different class inside the li elements.

    I've read the most of post in the forum, but nothing. if someone can show me a step by step for a newbie that would be great.

    The content is showed fine but i'm not sure how to do that.

    Thanks and sorry for my english.

     

  • Chris Koiak 700 posts 2626 karma points
    Feb 09, 2010 @ 21:10
    Chris Koiak
    1

    the following code will loop through the child pages of the current page and output a ul/li list.

    The class name on the li is chosen in the <xsl:choose> statement. Obviously the test statements need to be replaced.

          <ul>
    <xsl:for-each select="$currentPage/node">
    <li>

    <xsl:attribute name="class">
    <xsl:choose>
    <xsl:when test="1=1">
    <xsl:value-of select="class1"/>
    </xsl:when>
    <xsl:when test="1=2">
    <xsl:value-of select="class2"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="detaultClass"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:attribute>

    <xsl:value-of select="current()/@nodeName"/>
    </li>
    </xsl:for-each>
    </ul>
  • Mario 11 posts 31 karma points
    Feb 09, 2010 @ 21:18
    Mario
    0

    Hi Chris, thanks for your quick answer, but i don't need a menu through the child pages, only i'll need a list with ul li links. the user should be able for edit them later, delete and so on.

    the links will be able throught the whole site too, but it need be able for edit and without watching the child pages.

    I'm not sure if i explain this fine.

    Thanks

     

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 09, 2010 @ 21:24
    Morten Christensen
    1

    Hi Mario,

    How you render the li tag and class attribute depends on whether you choose to create a simple xslt or a usercontrol. I guess the simple approach would be to create a simple xslt like this - assuming that you add a textstring-type field on your Document Type:

    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <li>
    <xsl:attribute name="class">
    <xsl:value-of select="data [@alias = 'cssclass']" />
    </xsl:attribute>
    <a href="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-of select="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>
    </ul>

    The above example evaluates a set of children of the current node and renders an unordered list with the nodeName and a link to the page. Each of the children should be based on a Document Type, which has a Data Type (ie. textstring) with the following alias: cssclass
    Using the xsl:attribute function will add the speficied attribute name to the preceding tag with the xsl:value-of. Result would be something like:

    <ul>
    <li class="someclass"><a href="/somelink.aspx">First Node</li>
    <li class="anotherclass"><a href="/anotherlink.aspx">Another Node Name</li>
    </ul>

    Hope this is what you were looking for.

    - Morten

     

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 09, 2010 @ 21:28
    Morten Christensen
    0

    Guess I wasn't quick enhough to answer :)

    @Mario: Can you list your node tree structure for the pages or nodes that you want listed in your unordered list?

    - Morten

  • Mario 11 posts 31 karma points
    Feb 09, 2010 @ 21:34
    Mario
    0

    Hi Morten, thanks for your quick answer, i'm not sure if this is that i need. for example, here is the html code that i'll need build dynamic

    <div class="links">
                   
                        <ul> 
                            <li><a href="#">Technology</a></li>
                            <li><a href="#">Athletes</a></li>
                            <li><a href="#">Events</a></li>
                            <li><a href="#">Find a dealer</a></li>
                            <li class="cart"><a href="#">Cart</a></li>
                        </ul>
                       
                    </div>

    the links technology, athletes and so on need be dynamic but they should link to another places, not childs from the current node or something else. then the last link has the class "cart" for show different. i hope this clarify a bit more my question.

    Thanks and remember that i'm a newbie on umbraco ;)

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 09, 2010 @ 21:55
    Morten Christensen
    0

    Okay, I think I understand what you are trying to do.
    On your Document Type from which you want to add a list of links, add the Data Type called "Related Links" (alias: links). This Data Type allows you to add a list of internal or external links to your page.

    The xml for the Related Links Data Type looks like this:

    <links>
    <link
    title="Technology" link="#" type="external" newwindow=""/>
    <link title="Athletes" link="#" type="external" newwindow=""/>
    </links>

    You might want to check if the link is internal or external in order to decide how the link should be rendered and whether target="_blank" should be added to the a-tag.

    <xsl:for-each select="data [@alias = 'links']/links/link">
            <li>
    <xsl:if test="position() = last()">
                   
    <xsl:attribute name="class">
                            <xsl:text>
    cart</xsl:text>
                   
    </xsl:attribute>
    </xsl:if>
                    <a href="{@link}">
                           
    <xsl:value-of select="@title"/>
                   
    </a>
           
    </li>
    </xsl:for-each>

    In the above example I test for the position in order to add a css class name to the last li element in the unordered list.

    Is this what you are looking to do?

    - Morten

  • Mario 11 posts 31 karma points
    Feb 09, 2010 @ 23:03
    Mario
    0

    Hi Morten

    I've made the related links and set the alias, but i don't know how i'll can show then in the master template or in the home template. i'm reading about how make content but i think i'll need learn more about umbraco. i'm a newbie on this.

    you know if exist a tutorial step by step of how make this?

    I've read that this cms is easy to use, but i think not is very intuitive. maybe is because i'm changing from modx

    Thanks

     

     

  • Mario 11 posts 31 karma points
    Feb 10, 2010 @ 00:29
    Mario
    0

    Sorry morten to bother you again, can you explain step by step the message that you've post here a few ago with this message?

    On your Document Type from which you want to add a list of links, add the Data Type called "Related Links" (alias: links). This Data Type allows you to add a list of internal or external links to your page.

    Thanks

     

     

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 10, 2010 @ 12:21
    Morten Christensen
    0

    Hi Mario,

    First off here are some links to posts, which I hope you will find usefull in getting started with Umbraco:
    http://www.blogfodder.co.uk/post/A-Complete-Newbies-Guide-To-Umbraco-CMS.aspx
    http://www.blogfodder.co.uk/post/Using-Master-Document-Type-In-Umbraco.aspx
    http://www.blogfodder.co.uk/post/Simple-Umbraco-Footer-Navigation.aspx

    http://our.umbraco.org/wiki/how-tos/umbraco-absolute-beginner-tutorial

    and off course the www.umbraco.tv site. I highly recommend subscribing to umbraco.tv as it contains a huge amount of helpful videos.

    - Morten

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 10, 2010 @ 12:59
    Morten Christensen
    0

    Here is a step by step of how to create a page, which renders an unordered list of links. And this is from total scratch:

    First go to the Settings section and Document Types. Right click on Document Type and choose Create. For this example I'll call the Document Type "LinkList".
    Keep the "Create matching template"-checkbox checked, so a Template will be created for us. I'll return to the Template, but next step is to click on the newly created Document Type.

    On the LinkList-Document Type go to Tabs and create a new tab called Content. Now go to the Generic properties and add a new property. I will give my property the following values:
    Name: My Links
    Alias: myLinks
    Type: Related Links
    Tab: Content

    The important thing here is the Alias, which we will use in our XSLT and the Type, which is our selected Data Type of Type: Related Links (as per my previous post).
    Save the changes made to the Document Type, and move on to the Developer section. Here we will create our XSLT, which we will use to render our unordered list.

    Right click on "XSLT Files" and choose create. I have called my XSLT "LinkListRendering" and chose the Clean-xslt template and left the "Create Macro"-checkbox checked, as this will automatically create a Macro for us that we will use on the Template, which was automatically created when we created the Document Type.

    Paste the following code into your newly created xslt (LinkListRendering):

    <xsl:for-each select="$currentPage/data [@alias = 'myLinks']/links/link">
            <li>
    <xsl:if test="position() = last()">
                   
    <xsl:attribute name="class">
                           
    <xsl:text>
    cart</xsl:text>
                   
    </xsl:attribute>
    </xsl:if>
                    <a href="{@link}">
                           
    <xsl:value-of select="@title"/>
                   
    </a>
           
    </li>
    </xsl:for-each>

    and paste in after the following comment in the xslt:  <!-- start writing XSLT -->

    After saving your XSLT go back to the Settings section and choose the LinkList Template under Templates.
    Inside the <asp:Content> </asp:Content> tags insert a Macro (Insert Macro button in the top menu). Choose the Macro called "Link List Rendering" and click Ok. Now we have added our XSLT rendering to our Masterpage.

    If you go to the Content section and create a new document based on the LinkList-Document Type, add some links to your list and then publish you should see the unordered list rendered.
    You might need to allow creation of LinkList-documents by setting allowed types under the Structure tab on the different Document Types.

    I hope all of this made sense and it helped you create the unordered list you wanted.

    - Morten

  • Mario 11 posts 31 karma points
    Feb 10, 2010 @ 15:37
    Mario
    0

    Hi Morten, thanks for your step by step guide. i've does the all steps, but i continue without watching the link in the site. i've loaded into the master template and nothing. i've read the all documentation that you've told me before but is like this cms not is for an newbie.

    how i'll can load the link list into the master template?

    Thanks man and sorry to bother each time

    Best,

     

    Mario

  • Mario 11 posts 31 karma points
    Feb 10, 2010 @ 19:36
    Mario
    0

    I've made the step by step a few times and nothing, in the master template i've added this and nothing

     <umbraco:Macro Alias="LinkListRendering" runat="server"></umbraco:Macro>

    then the struture of my site is the next

    templates

         LinkList
         Master (with a lot of childs)
         RSS
         XML Sitemap

    I know that i'm not an expert in this, but what step i am doing bad? :(

    thanks for the help

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 10, 2010 @ 20:03
    Morten Christensen
    4

    Hi Mario,

    I'm not sure I can explain it any better, so I have made a quick screencast of the step-by-step that I wrote in an earlier post. I hope seeing the steps in action will help you succeed in your creation of the unordered links.

    Check it out here:http://screenr.com/pTx

    - Morten

  • Mario 11 posts 31 karma points
    Feb 10, 2010 @ 21:42
    Mario
    0

    Hi Morten, thanks for you help, you can think that i am idiot but i've does the all steps and fine works, but how i can insert into the template for show in the whole site?

    i mean i've has a master template and inside it i have a lot of templates, but i need that this list is showed in the all sites.

    i've installed a package (CWS) and i'm changing the code from this place.

    Sorry and thanks again.

    Mario

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 10, 2010 @ 22:12
    Morten Christensen
    0

    Hi Mario, No problem! You are not an idioit, just new to the system which is totally understandable.

    If you want the list displayed on every page you would have to add the Macro within this tag:

    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server"></asp:Content>

    I think the last thing you are missing is that the current example uses currentpage as the starting point for creating the list. But I'm guessing the list only resides in one place within your content tree.
    Lets say your list of links is placed on the Home node (i.e. the Related Links-Data Type on your Home-Document Type), you could use this xsl variable to get the correct starting point (which is Home on the CWS website package or simply the first level node):

    <xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::node [@level=1]" />

    and then change the following line to use the rootNode variable instead of currentPage:

    <xsl:for-each select="$rootNode/data [@alias = 'myLinks']/links/link">

    Try it out and let me know if it works.

    - Morten

  • Mario 11 posts 31 karma points
    Feb 10, 2010 @ 22:36
    Mario
    0

    Hi Morten, :(
    nothing happened, here is the structure that now i have
    Templates
            LinkList
            Master
                Contact
                Email a Friend
                Event Item
                Galleries
                ...
                Home
                ....
                Textpage(Two Column)
            RSS
            XML Sitemap
    .....
    Document Types
            Contact
            .....
            Home
            LinkList
            ....
            Textpage(Two Col)
    In the document type LinkList the allowed templates is
    LinkList and Master.
    Inside the Master Template i've added this
      <umbraco:Macro Alias="LinkListRendering" runat="server"></umbraco:Macro> and nothing is showed.
    the call to the function it's inside a global
    <asp:Content ContentPlaceHolderID="ContentPlaceHolderDefault" runat="server">

    I know that is a simple thing but i don't understand good how works this CMS. i've saw a lot of videotutorials and i'm continue learning about this.
    Thanks for you help, and tell me if is wrong something
    Thanks!!!!

    Mario

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 10, 2010 @ 23:15
    Morten Christensen
    0

    Okay, can you try and explain where you want the list rendered on your site. You mentioned that it should be shown on all pages, but is it like a top menu, left menu or footer where you type the links instead of generating the list from child elements?

    I think you could drop the LinkList Document Type and Template, and simply add the Related Links-Data Type to your Master-Document Type, but i'm not 100% sure that this is what you want...? Do you want to be able to create the links on one central node? A good example would be an address, which is only entered on the Home node, but shown on all pages in the footer.

    - Morten

  • Mario 11 posts 31 karma points
    Feb 11, 2010 @ 04:36
    Mario
    0

    this is my requirement. i'll need add a few list in different places of the master template with links, these links need be edited for the client in an easy form.

    For example, have header links, sidebar links and footer links, but not with the child pages and so on. only links.

    sorry for my english and thanks for all

    Best,

     

    Mario

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 11, 2010 @ 18:39
    Morten Christensen
    1

    Mario, I'm setting up CWS locally so I can create a screencast in your context. I'm pretty sure my last post should have worked, but you might have missed something or something is different because of the context.

    Stay tuned! A new example is coming up ;)

    - Morten

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 11, 2010 @ 22:49
    Morten Christensen
    1

    Hi Mario,

    Here is a screenr of inserting lists of links on the Master of the CWS package. What I have done is to add two tabs (Header Links and Sidebar Links) on the Home-document type, and afterwards added the Related Links data type on each tab.

    Next I created two XSLTs with matching Macros: HeaderLinks.xslt and SidebarLinks.xslt - I added the code, which i previously posted. Back to the Settings section, I added the two Macros to the Master (Masterpage).

    Lastly I go to the content section and the Home node, and add links to the two fields (one field on each tab). Save and Publish, then click the link to go to the updated page.

    Here is the screenr: http://screenr.com/A2x

    I have created an Umbraco package, which you can download and install - try installing it in a fresh umbraco solution. If you also install CWS before installing the package there might be some conflics, but its worth trying out.

    Download the package from here: http://c0198291.cdn.cloudfiles.rackspacecloud.com/LinkLists_1.0.zip

    Download the complete solution with CWS installed and 2008 database backup: http://c0198291.cdn.cloudfiles.rackspacecloud.com/UmbracoCWS.rar

    Hope this does the trick.

    - Morten

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Feb 14, 2010 @ 10:01
    Morten Christensen
    0

    Maybe I should add that the login to umbraco for the attached db is (u/p): admin / b

    When installing you only have to change the connectionstring in the web.config, and you should be up and running.

    Again, hope this example gets you on the right path.

    - Morten

  • Mario 11 posts 31 karma points
    Feb 15, 2010 @ 19:02
    Mario
    0

    Hi Morten, Thanks yeah!!! That works fine ;)

    Thanks again

    Best,

     

    Mario

Please Sign in or register to post replies

Write your reply to:

Draft