Skip to content

Import from external URL into Body

edited May 2013 in Suggestions

in create.php just add this after line 163

<div class="input-append">
                          <input type="text" class="input-xlarge" id="import-uri" name="import-uri" placeholder="HTML para Importar"> <a id="import-now" href="#" class="btn" id="import_html">Importar HTML</a>
                          <script>
                          $("#import-now").click(function() {
                            var uri = $('#import-uri').val();
                            $.post('import-html.php', { uri: uri },function(data) {
                                              $('#html').html(data);
                                              alert(data);
                                            });
                                            return false;
                                        });
                          </script>
                        </div>

and then create a file called import-html.php and write this in it

<?php $url = $_POST['uri']; $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); $output = curl_exec($curl); echo $output; curl_close($curl) ?>

it's a quick way to add an "import from other site" field so you don't have to copy the source if you have a template generator

Comments

  • I was just looking for this! Thank you for this.
    But you're using $('#html').html(data);. That didn't work for me. I changed $('#html').html(data); to $('#html').val(data);. That works much better!

    Hopefully this will be included in the next update!

  • edited July 2014

    Hi, I'm trying to get this to work, but it doesnt appear to update the code in the editor, just get a big alert with the code in which I hit OK but it doesnt update - here's how I have it:

      <div class="control-group">
                                                    <div class="controls">
                                                  &gt;textarea class="input-xlarge" id="html" name="html" rows="10" placeholder="Email content"></textarea>
                                                </div>
                                            </div>
    
    <div class="input-append">
                              &gt;input type="text" class="input-xlarge" id="import-uri" name="import-uri" placeholder="HTML Import"> <a id="import-now" href="#" class="btn" id="import_html">Import HTML</a>
                              <script>
                              $("#import-now").click(function() {
                                var uri = $('#import-uri').val();
                                $.post('import-html.php', { uri: uri },function(data) {
                                                  $.post('#html').html(data);
                                                  alert("got it);
                                                });
                                                return false;
                                            });
                              </script>
                            </div>
    

    the line counts are not the same as in your example - and I cant figure out how to get the code to display properly using markdown. Sorry!

  • Hi,
    Did you solve this issue? I have the same problem, and I need to import code from a external url.

    Any suggestion? Other way to solve this?

    thanks

  • I am trying this code on Sendy Version 2.1.2.5 and it seems to work, but it doesn't work as expected.

    When I click the "Importar HTML" button, it waits a few moments and then a pop-up modal window shows the HTML code from the URL. I then manually copy and paste that into the HTML Code window and send my message.

    However, I expect it to work like this:
    1) Add the URL and click submit, and the HTML Code window will be automatically be populated with the HTML. This means the copy/paste is unnecessary.

    2) I want to schedule sends to send every day. And every day they should grab the latest content from a particular URL. I wanted this script to do that, but it doesn't do it... anyone know of a method to handle this in Sendy?

Sign In or Register to comment.