Copied to clipboard

Flag this post as spam?

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


  • hookbeak 5 posts 25 karma points
    Sep 16, 2009 @ 14:34
    hookbeak
    0

    Trying to create a news section...

    Hi guys,

     

    I'm new to umbraco and having a *lot* of problems with it, even after watching the videos i find it very, very difficult to navigate.

    I'm trying to create a news section, this would be a seperate section but also would pull the top XX stories into the front page.

    I created the templates, added the pages and content but can't find how to pull the pages into the homepage.

    Can anyone point me in the right direction ?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 16, 2009 @ 14:48
    Dirk De Grave
    1

    hookbeak,

     

    Ok, let's try using an example (I'll have to make some assumptions here, up to you to substitute with correct names...)

    -Go to developer section, create an xslt file (check to create macro) 'News', choose empty template.

    -Paste following code snippet after "Fun is starting here"

    <ul>
      <xsl:for-each select="$currentPage/ancestor-or-self::node [@level = 1]//node [@nodeTypeAlias = 'News']">
        <li><xsl:value-of select="@nodeName"></li>
      </for-each>
    </ul>

    (Must subsititute 'News' with the alias of a news item document type)

    -Save template

    -Expand the macro node and select 'News' macro and verify whether the macro references the 'News' xslt.

    -Go to your template that will render the homepage and use the dialog to insert a macro (icon in menu bar of template editor)

    -Select 'News' from the list.

    -Save template, browse to your homepage and you should get a list of pages that are news items

     

    If still unclear or want more info, let us know.

     

    Hope this helps.

    Regards,

    /Dirk

     

  • hookbeak 5 posts 25 karma points
    Sep 16, 2009 @ 14:53
    hookbeak
    0

    hi dirk,

    Is it possible to have umbraco show a list of a *specific* node ?

    i have this kind of layout :

    home
    |----------- NEWS
    |                     |-Newsitem1
    |                     |-Newsitem2
    |----------- Other section
    |----------- Third Section


    And the macro is returning

    NEWS
    OtherSection
    ThirdSection

    instead of the
    NewsItem1
    Newsitem2

    that i'd like

     

     

    Andy

     

  • hookbeak 5 posts 25 karma points
    Sep 16, 2009 @ 14:59
    hookbeak
    0

    Actually, ignore my last post - i'm being dumb !

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Sep 16, 2009 @ 15:05
    Nik Wahlberg
    0

    Andy, can you provide the XSLT that produces the above output? It's easier for us to modify/help with what you currently have. To address the *specific* type that you are looking for, please see Dirks post that talks about 'nodeTypeAlias'. The nodeTypeAlias points to the name of a specific DocumentType that you would have setup in the 'Settings' section. It is necessary/useful to separate your various types of content into DocumentTypes. Not only to distinguish between them, but also to be able to specify different attributes for different types.

    For example, a 'standard' page/document type would in all likelyhood only have

    - Page Heading
    - Body Text

    Whereas your news document type would probably have things like:

    - Date
    - Title
    - Description
    - Summary
    - ...

    Not sure if you've gotten this far already. If you have, please disregard.

    Cheers,
    Nik

  • hookbeak 5 posts 25 karma points
    Sep 16, 2009 @ 17:26
    hookbeak
    0

    hi guys,

    thanks for the help so far :

      <xsl:for-each select="$currentPage/ancestor-or-self::node [@level = 1]//node [@nodeTypeAlias = 'News Item']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>

    can anyone tell me how to change this XSL so that it would pick up all 'NewsItem' templated pages independent of location:

    My structure is like this:

    -home page
    - News
         |-News1
         |-News2

    They are appearing on page "news", but i can't pull them into "home page " as well.....

     

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 16, 2009 @ 18:02
    Dirk De Grave
    0

    My code snippet should really do the trick, as it selects all nodes ('//' selector') regardless of their level, after having traversed upwards until it finds a node with level = 1, but you should restructure your site to only have a single top level node (in your case, that would be 'Home'). It's best practice to have a single top level node ('Home') and put all other stuff on a lower level (as child nodes from 'Home'). If you still want to use your approach, you'd need better create a macro parameter  (alias="newsNode", type = content picker) and use that parameter value in your xslt:

    <xsl:variable name="newsContainerNode" select="/macro/newsNode"/>

    and change xslt for-each to use this variable:

    <xsl:for-each select="umbraco.library:GetXmlNodeById($newsContainerNode)/node">
      ...
    </xsl:for-each>

    (Might get an error when saving, just for now, check the 'Skip errors' box)

    Macro call in the template will need some mods to include the new parameter

    <umbraco:Macro alias="" newsNode=""></umbraco:Macro>

     

    Hope this helps.

     

    Regards,

    /Dirk

     

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Sep 16, 2009 @ 18:51
    Nik Wahlberg
    0

    What Dirk is suggestion are both valid. In case any of them don't work for you (for whatever reason) you should alos consider using GetXmlAll() (one of my personal favorites). So, it would look something like this:

    <xsl:variable name="documentTypeAlias" select="string('News Item')"/>
    <xsl:variable name="data" select="umbraco.library:GetXmlAll()/descendant-or-self::node [@nodeTypeAlias = $documentTypeAlias and string(data [@alias='umbracoNaviHide']) != '1']"/>

    This snippet also ensures that it strips out any nodes that are maked to be hidden via the standard umbracoNaviHide property. Then, to loop over the data you would do something like:

    <xsl:for-each select="$data">
      <xsl:value-of select="@nodeName" />
    </xsl:for-each>

    What this will allow you to do is use this snippet ANYWHERE in the site as it is not dependant on traversing the XML based on $currentPage.

    Hope this helps.

    -- Nik

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies