Copied to clipboard

Flag this post as spam?

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


  • Michael Jensen 29 posts 98 karma points
    Apr 12, 2014 @ 22:21
    Michael Jensen
    0

    Text Problem in macro

    Hey,

    iam tryning to get the text in my images slider to show up right.

    my problem is i need to ude a RTE to enter the text becors it might need to put a link in the text,

    the problem is if i do a forline break whit enter the text fucks up and stant over ethoter.

    I belive the problem is that the RTE makes p Tages on evry line break, and i belive i need to remove them but dont knowe hove to

    This is the propeties on the DT:

    Image is a Uploade

    captionText is a Rich Text Editor

    Iam running on a windows 2012 server whis 2012 MSSQL server DB,

    The Umbraco version is Umbraco v6.1.6 (Assembly version: 1.0.5021.24867)

    The Page is live AT this link  

    i have made 2 slides one whit no breaks and one whit

    Best regards
    Michael

    This it my macro:

    @inherits umbraco.MacroEngines.DynamicNodeContext
    @{
    var startNodeID = Parameter.nodeId;
    }
    @if (startNodeID != null)
    {
    @* Get the start node as a dynamic node *@
    var startNode = Library.NodeById(startNodeID);

    if (startNode.Children.Where("Visible") .Any())
    {
    <ul class="slides">
    @foreach (var page in startNode.Children.Where("Visible"))
    {
    <li>
    <img src="@page.Image" />
    <p>@page.captionText</p>
    </li>
    }
    </ul>
    }
    }
  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 12, 2014 @ 22:31
    Jan Skovgaard
    100

    Hi Michael

    Well you could use the .stripHtml() function...but I think it would make more sense if you rewrote your output html and changed the <p> element to a <div> element that you then apply the absolute styling too instead. Then the natural line breaks on the p element will be kept intact. You can always adjust margin, padding, font-size and line-height to suit your design. So simply do this

       if (startNode.Children.Where("Visible").Any())
        {        
           <ul class="slides">
              @foreach (var page in startNode.Children.Where("Visible"))
             {
                  <li>
                     <img src="@page.Image" />
                        <div>@page.captionText</div>
                   </li>
                }
          </ul>
        }
    

    And then of course change your CSS.

    Hope this helps.

    /Jan

  • Michael Jensen 29 posts 98 karma points
    Apr 13, 2014 @ 12:07
    Michael Jensen
    0

    Hi Jan,

    Thanks for the advice, the sec i look at it i knew i had ask at smaler stupid question, i dint think a DIV will work so therfor i dint try it first.

    but it works knowe and thanks.

     

    /Michael

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Apr 13, 2014 @ 12:13
    Jan Skovgaard
    1

    Hi Michael

    You're very welcome - no questions are too small to be asked. The forums are also meant for having another pair of eyes on your code and your thinking. Sometimes that is what is needed in order to see the proper solution and learn something. So don't be afraid to ask - as long as you learn and progress...maybe someone else will also benefit from reading your post sometime in the future :)

    Have a nice sunday.

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft