Copied to clipboard

Flag this post as spam?

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


  • Carlos 338 posts 472 karma points
    Oct 21, 2013 @ 20:27
    Carlos
    0

    Razor, Richtext Editor, Get rid of line breaks

    I am using the richtext editor to output some text onto my page. Pretty basic.

    The issue is, I need the RichText editor to NOT line break in the middle of the sentences.

    This is out my output is looking in my source:

    <p><strong>On Permanent Display</strong><br />
    
     Shelter. Food. Clothing. Tools. Experience the incredible
    
    diversity among Native American groups and the practicality and
    
    artistry of their everyday objects.</p>
    

    You can see the lines break right in the middle of the paragraph tags.

    What could be causing this and can I fix this?

    EDIT: This is more or less what I am trying to do with my page. Because of the random line breaks the HTML is not actually outputting out a straight string.

    <script>
                    $(document).ready(function(){
                        if($(window).width() > 767){
                            $("#webpageTemplate-Col1").html('<umbraco:Macro numberOfResults="2" Alias="CrossPromotions" runat="server"></umbraco:Macro>'); 
    
                        }
                    });
                </script>
    
  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Oct 21, 2013 @ 23:56
    Chriztian Steinmeier
    0

    Hi Carlos,

    You need to look at the CrossPromotions macro and make sure that it outputs to a single line (and that it escapes single quotes). Basically that macro should be written with that in mind, instead of as a traditional macro generating HTML...

    I'm having a little difficulty in understanding the reasoning for generating the HTML by way of JavaScript? Why is that?

    /Chriztian

  • Carlos 338 posts 472 karma points
    Oct 22, 2013 @ 00:04
    Carlos
    0

    Thanks Chriztian,

    Mainly it is because we don't want the cross promos macro to show if the screen size is less than 767px. That is because our CrossPromotions macro searches through ALL the nodes in our site (approx. 8000) and then determines if the cross promo matches has the same property as the current page. We are using Responsive CSS for our mobile layout, so the Macro takes a bit of time to load on mobile devices because of the resources the CrossPromotions are taking to render onto the page. I have the display:none for the mobile layout, but the CrossPromotions still render in the page, and the we don't want the CrossPromotions macro to get inputted into the HTML if the screen size is below 767px. But thinking it through now, the macro is still loading either way in the Javascript.

    Hmmm. Not a good solution I guess. Might need to rethink this. We are using Umbraco 4.9.1 with webforms. We are not on MVC yet. I was trying to find a good way to load the macro ONLY if the page was above 767px. I know the 51Desgrees.mobi thing does screen size detection, but I don't really want to rely on another third party detection just for something as simple as rendering a Macro.

    Do you have any ideas? Hopefully this all made sense.

    Carlos

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Oct 22, 2013 @ 00:21
    Chriztian Steinmeier
    100

    Hi Carlos,

    That was exactly my follow-up point: The HTML is loading anyway, so that would almost end up as a penalty for small devices :-)

    If you need separate content, you could use the jQuery#load() method, and serve the content from a URL, either using an alt-template, or using Neehouse's Macro Service package.

    Then you could do something like this instead:

    <script>
    $(document).ready(function() {
        if ($(window).width() > 767) {
            $("#webpageTemplate-Col1").load('/promotions/ajax?results=2');
        }
    });
    </script> 
    

    /Chriztian

  • Carlos 338 posts 472 karma points
    Oct 22, 2013 @ 00:25
    Carlos
    0

    @Christian,

    We were doing the alt-templates a while back, but opted to shy away from it because of the multiple templates to manage. The Macro service looks like an interesting package.
    Thanks for the info I appreciate it.

Please Sign in or register to post replies

Write your reply to:

Draft