@jordanshotwell (Jordan Shotwell) posted a new topic, subject "Preview vs Published". It read:

   I'm getting a strange error where after publishing, one column's content appears to be nested inside the other. The first screenshot below shows how the content looks after publishing, and the second with how it looks in the preview and how it should be formatted. Anyone have any idea why this is occurring? Public link is here.
    
    ##  After publishing
    
    1280×939 88.6 KB
    
    ##  In preview
    
    1280×887 62 KB

So @vincent (Vincent Bidaux) replied

    Can you try to remove everything but SCRIPT here ?
    
    http://vincent.polenordstudio.fr/snap/9tvtl.png

@jordanshotwell (Jordan Shotwell) replied

    @vincent that corrected the issue of the image not showing up, but now the custom code to display the text in that section doesn't work. No text displays after you remove the other code. I only left the script that you highlighted.
    
    1401×518 331 KB
    
    754×171 17.1 KB

So @jordanshotwell (Jordan Shotwell) replied

    Any idea @vincent?
    
    @cyberdave @pixelgeek @sabanna @bart

@sabanna (Anna) replied

    Hi @jordanshotwell,
    
    Try to change the code snippet in the 2nd embed widget to this one:
    [code] 
        <script>
        function injectDay() {
          var days = ['Honey Dark Rum', 'Maple Bourbon Pecan', 'Sea Salt Pretzel', 'Plain Jane', 'Honey Dark Rum',
                  'Chocolate Peanut Butter', 'Sea Salt Pretzel'];
          var date = new Date();
        ​
          return days[date.getDay()];
        }
        ​
        Webflow.push(function() {
          $('.day-flavor .text').html(injectDay());
        });
        </script>
        
         <div onload="injectDay()">
            <div>
              <h3 class="dayContainer"></h3>
            </div>
         </div>
        
    [/code]
    
    Regards,  
    Anna

Then @jordanshotwell (Jordan Shotwell) said

    Hey @sabanna. That appears to have fixed the image, but not the Day text in column 1.
    
    1263×636 335 KB

Then @sabanna (Anna) said

    Right now published site and read-only link shows old code so I can't really see why it doesn't work. Could you, please change the code and publish the site?

After which, @jordanshotwell (Jordan Shotwell) added

    Sorry, published and read-only link changed. Here they are.
    
    Published
    
    Read only

Then @samliew (webflowexpert.com) said

    Please delete the embed component for the text, open up the page settings, and paste this in the last textarea:
    [code] 
        <script>
        function injectDay() {
          var days = [
            'Honey Dark Rum', 
            'Maple Bourbon Pecan', 
            'Sea Salt Pretzel', 
            'Plain Jane', 
            'Honey Dark Rum',
            'Chocolate Peanut Butter', 
            'Sea Salt Pretzel'
          ];
          return days[new Date().getDay()];
        }
        var Webflow = Webflow || [];
        Webflow.push(function() {
          $('.day-flavor.text').html(injectDay);
        });
        </script>
        
    [/code]

After which, @jordanshotwell (Jordan Shotwell) added

    That worked perfectly @samliew. Thanks for your help too @sabanna and @vincent!

After which, @jordanshotwell (Jordan Shotwell) added

    @samliew @sabanna any idea how to use a similar script to inject a specific URL instead of the flavors above, based on the day? I'm trying to build a corresponding link for each of the daily flavors listed in the script above. The ecommerce platform I'm using allows me to implement buy buttons (which I'm using on the “Flavors” page) but I'd love to be able to change the URL based on the day, so that users can add it to their shopping cart directly from the “Flavor of the Day” section. Any ideas?

Then @samliew (webflowexpert.com) said

    [code]
        <script>
        function injectUrl() {
          var urls = [
            'http://google.com', 
            'http://yahoo.com', 
            'http://samliew.com', 
            'http://webflow.com', 
            'http://youtube.com',
            'http://microsoft.com', 
            'http://apple.com'
          ];
          return urls[new Date().getDay()];
        }
        var Webflow = Webflow || [];
        Webflow.push(function() {
          $('#day-url').attr({
            href: injectUrl(),
            target: '_blank',
          });
        });
        </script>
        
    [/code]
    
    Insert a text link onto your page. Go to the settings tab and insert this ID: `day-url`

@jordanshotwell (Jordan Shotwell) replied

    @samliew that worked like a charm. Genius!

To which @system (system) replied

    This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.


{'source': 'discourse', 'url': 'https://discourse.webflow.com/t/preview-vs-published/25728', 'title': 'Preview vs Published', 'views': 1827, 'has_accepted_answer': True, 'word_count': 562, 'like_count': 1, 'reply_count': 8, 'participant_count': 4, 'posts': 14, 'tags': '', 'author': '@jordanshotwell (Jordan Shotwell)', 'participants': '@jordanshotwell (Jordan Shotwell), @vincent (Vincent Bidaux), @sabanna (Anna), @samliew (webflowexpert.com), @system (system)', 'image_url': ['https://global.discourse-cdn.com/business5/uploads/webflow1/optimized/2X/6/6f51a10ae012b56c8b887de142ec6178bd5dbedc_2_1024x751.png'], 'created_at': '2016-03-07T21:59:27.278Z', 'last_posted_at': '2016-05-23T13:55:26.727Z'}