Copied to clipboard

Flag this post as spam?

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


  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 11:45
    dominik
    0

    Manual Line Break in Headline

    Hi everybody,

    is there any way to include a manual break inside a headline (for example if it is really long). In other CMS this is for example a pipe "|" which forces a line break.

    Would be great if someone can help

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 29, 2011 @ 11:57
    Jan Skovgaard
    0

    Hi Dominik

    I guess you could also use a pipe in your headins in umbraco and then when you fetch the value using a macro based on XSLT for instance you can use the umbraco.library:Replace extension to replace the "|" sign with a <br /> element.

    Hope this helps.

    /Jan

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 12:03
    dominik
    0

    I put some <br /> Inside the title and use disable-output-escaping="yes" inside my xslt.

    This works but the link is not in the correct way. How can i ensure that the URL is not like:

    http://domain.de/test/this-is-a-very%3Cbr-%3E-long-navigation-point.aspx


    So the <br /> tag should not appear in the URL - everytime i put an <br /> inside it should be ignored

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 29, 2011 @ 12:37
    Jan Skovgaard
    0

    Hi Dominik

    What does the XSLT file look like?

    /Jan

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 12:42
    dominik
    0

    now i´ve got the following xslt which replaces the | with <br> and it works

    <xsl:value-of select="umbraco.library:Replace(@nodeName, '|', '&lt;br&gt;')" disable-output-escaping="yes"/>

    but the urls should ignore any special character otherwise i can not reach the url

    Umbraco try to go to a url like this-is-a-very<br>long-test.aspx

     

     

  • Rich Green 2246 posts 4008 karma points
    Mar 29, 2011 @ 12:44
    Rich Green
    0

    Dominik,

    Just create another property named "headline" and use this instead of the @nodeName, then you can have one normal and one with whatever breaks you need.

    You can also default to the @nodeName but use the headline when you need to override it.

    Rich 

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 12:52
    dominik
    0

    Oh but this an entry more for the user who is using the backend. Is there no possibility of not parsing | or <br> in the URL?

    so look if there is a | or <br> inside the nodeName and if yes replace it with '' but only in the URL?

  • Rich Green 2246 posts 4008 karma points
    Mar 29, 2011 @ 12:58
    Rich Green
    0

    Yes, the user would enter the information in the backend, if they need a line break they enter the headline into a Rich Text Area, if not then they leave it empty.

    Certainly you can strip out whatever you want from the URL, but the doesn't seem logical to me.

    Rich

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 13:01
    dominik
    0

    So you would create a new property called "longURL" am i right?

    And than i have to check on each XSLT script if longURL is filled out and if not use nodeName?

    Is this the correct solution?

    Thanks

  • Rich Green 2246 posts 4008 karma points
    Mar 29, 2011 @ 13:05
    Rich Green
    0

    That's what I would do yes.

    The property is not for a URL though right?  It's just to display a longer <h1>headline</h1> on the page that maybe different to the nodeName, or did I understand you incorrectly?

    Rich

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 13:08
    dominik
    0

    I need this information for display the headline and the Link of the URL in the navigation.

    For example if The URL does not fit in a navigation box we have to cut. This could be done via css but than it is cutted on any characters so the backend user should control this by pasting a | after the char the item should be splitted into two lines

    Hope now you understand what i want to do

  • Rich Green 2246 posts 4008 karma points
    Mar 29, 2011 @ 13:17
    Rich Green
    2

    Hey,

    Makes sense.

    Basically create a property called 'headline' (or longURL if you want but doesn't make sense really as you are not using it for the URL)

    When you need to use the <h1>Headline</h1> in xslt you

    - check to see if 'headline' is blank,

    - if not use headline

    - otherwise use @nodeName as the headline

    Then when you want to show a link you can always use:

    <a href="{umbraco.library:NiceUrl($currentPage/@id)}">
     <xsl:value-of select="$currentPage/@nodeName" />
    </a>

    Hope I understood you correctly

    Rich

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 29, 2011 @ 13:28
    Jan Skovgaard
    0

    Hi Dominik

    I don't have much to add to what Rich is saying but I thought you were already using a text property and not the @nodeName property. Plings should not occur in a link :-)

    /Jan

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 13:48
    dominik
    0

    But one thing.

    If I am using your method the URL can be a complete other than the headline - this should not be.

    I need the Title (nodeName) to be displayed as Headline and as Navigation Link Text.
    But I have to brake sometimes the link if it is too long.

    It would be great if there is a other possibilty as create a new "headline" tag. This will confuse the backend user.

    I just want to add a | to the nodeName everytime the user wants to brake the Text.

    But the URL does not work if I add a pipe for example

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 29, 2011 @ 14:21
    Tom Fulton
    0

    Hi dominik,

    One possible solution that might help is the Jesper's Easy Values package.

    This would allow you to create a separate field called Headline, but it would be automatically populated with the name of the node upon creation.  It's a great helper to Rich's idea because it saves the user from having to input again (unless they want to change).

    To use it all you have to do is install, and name your headline field umbHeadline.  You could also make this a textbox multiple field so line breaks can be entered (you'd need to replace with <br/> in XSLT).

    I use this in all my solutions.

    -Tom

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 14:25
    dominik
    0

    Thanks Tom,

    Is there no other solution as adding a new "Headline" line - because than i have to edit all of my different document types, xslt files etc.

    Just want to replace the "|" in the URL with "null" so I can reach the URL

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 29, 2011 @ 14:26
    Tom Fulton
    0

    You should be able to get rid of | in URL's by editing /config/umbracoSettings.config in the URL Replacement section.  You can specify that | gets replaced with nothing.

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 14:30
    dominik
    0

    Ok but still get the error 404 - site not found

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 29, 2011 @ 14:33
    Tom Fulton
    0

    You get 404 when doing what?  Trying to access a URL with a pipe still in it?  You might need to republish your pages to get rid of the pipe from the URL.

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 14:34
    dominik
    0

    oh ok sorry :-)

    It works now - but just saw in the template i am using :

    <umbraco:Item field="pageName" runat="server"></umbraco:Item><umbraco:Item field="siteName" runat="server"></umbraco:Item>

    I need to also replace | with <br /> here - how can I handle this outside my template?

     

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 29, 2011 @ 14:35
    Tom Fulton
    0

    You can use inline XSLT on umbraco:item tags, ex:

    <umbraco:Item field="pageName" runat="server" Xslt="umbraco.library:Replace({0}, '|', '<br/>')"></umbraco:Item>
  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 14:41
    dominik
    0

    oh ok and

    disable-output-escaping="yes"

    i can also add?

    Until now it writes <br />

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 29, 2011 @ 14:45
    Tom Fulton
    1

    Hmm...sorry, not sure how you'd handle that.

    As a workaround you could create an XSLT macro to use instead of <umbraco:Item> in those cases and pass the field name in as a parameter.

  • dominik 711 posts 733 karma points
    Mar 29, 2011 @ 14:47
    dominik
    0

    so i can not use disable-output-escaping in the Template?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 30, 2011 @ 19:10
    Jan Skovgaard
    0

    Hi Dominik

    I don't suppose you can when using inline XSLT.

    As Tom is saying you're probably better of using a XSLT macro to handle this instead.

    It's always a good idea to consider how much you need to manipulate the value that should be displayed on the website. If you have to do things like replace or truncate or stuff like that then you need to use a macro.

    If you just need to fetch the value then you should simply just use an umbraco:item.

    Hope this helps.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft