Helpful Docs to read before posting: (All Docs) | Config Docs | General FAQ | Mailing List Sending FAQ | Error FAQ

Can't assign an external template

What else do you want to hook Dada Mail to?

Can't assign an external template

Postby disonancias » Sun Mar 25, 2012 9:13 pm

Hello,

I'm trying to set up for a client a couple of mailing lists using Dada Mail. The goal is to fully integrate the subscription process into his website (WordPress-based PHP/MySQL), and since I can't use PHP code inside the Dada admin panel, the only option I have is to use external templates.

So, I log into the admin panel, go to Appearance and Templates / Your Mailing List Template, choose the last option (Use the Custom Template at this URL for your Mailing List), and provide the URL of the template that Dada is supposed to use. All I get is this error message:

Yikes! Problems fetching the below URL. Please check the URL and try again.

I first assumed my template was lacking some custom tag, so I copied the default one and tried it that way. Same result. The file extension also doesn't matter, it keeps showing the same error message despite the file being .htm, .html or .php.

I really don't know what else to try. I'm open to suggestions :)

Thanks in advance,

Ricardo
disonancias
 
Posts: 5
Joined: Sun Mar 25, 2012 9:01 pm

Re: Can't assign an external template

Postby justin » Sun Mar 25, 2012 9:45 pm

Who's your host? And can you give an example of a URL you're trying to use?

Does the, "Send a Webpage" screen also give you some sort of error?
User avatar
justin
 
Posts: 4581
Joined: Wed Feb 13, 2008 8:41 pm
Location: Denver, CO

Re: Can't assign an external template

Postby disonancias » Mon Mar 26, 2012 9:03 am

- We're hosted at eTowers (www.etowers.net), using Pro Dada.

- Examples of the URLs I tried:
http://mydomain.com/templatename.php
http://mydomain.com/templatename.htm
http://mydomain.com/templatename.html
http://mydomain.com/templatename/
/home/public_html/<same template filename>

- The "Send a Webpage" feature seems to work fine.
disonancias
 
Posts: 5
Joined: Sun Mar 25, 2012 9:01 pm

Re: Can't assign an external template

Postby justin » Mon Mar 26, 2012 10:34 am

Can you give actual URLs you're trying to use? I was actually going to try to test them :)
User avatar
justin
 
Posts: 4581
Joined: Wed Feb 13, 2008 8:41 pm
Location: Denver, CO

Re: Can't assign an external template

Postby disonancias » Mon Mar 26, 2012 11:42 am

Sorry :) You can try these two:

http://rm-forwarding.com/template-dada.php
http://rm-forwarding.com/template-dada.htm

They're exact copies of the standard template.
disonancias
 
Posts: 5
Joined: Sun Mar 25, 2012 9:01 pm

Re: Can't assign an external template

Postby justin » Mon Mar 26, 2012 12:36 pm

I think your webserver is blocking the calls Dada Mail is making to your site, because of the user agent. You can try hacking Dada Mail, to use a different user agent:

In Dada Mail, find these lines:

Code: Select all
            if ( $can_use_lwp_simple == 1 ) {
            
                if ( LWP::Simple::get( $li->{url_template} ) ) {
               my $tmp_tmpl = LWP::Simple::get( $li->{url_template});
               if($tmp_tmpl =~ m/$content_tag/){
                  $content_tag_found_in_url_template = 1;
               }
                }
                else {

                    $template_url_check = 0;

                }
            }


You'll need to change this to something like:

Code: Select all
if ( $can_use_lwp_simple == 1 ) {
            
                #if ( LWP::Simple::get( $li->{url_template} ) ) {
                use LWP::Simple qw/get $ua/;
            $ua->agent("Dada Mail"); # Change, Dada Mail to whatever you'd like
            if ( get( $li->{url_template} ) ) {
               my $tmp_tmpl = get( $li->{url_template});
               if($tmp_tmpl =~ m/$content_tag/){
                  $content_tag_found_in_url_template = 1;
               }
            }
                else {

                    $template_url_check = 0;

                }
            }


As well as in dada/DADA/Widgets/HTML.pm - find:

Code: Select all
sub open_template_from_url {
   my %args = (
               -URL  => undef,
               @_,
             );
         
   if(!$args{-URL}){
      carp "no url passed! $!";
      return undef;
   }else{
      eval { require LWP::Simple };
      if($@){
         carp "LWP::Simple not installed! $!";
         return undef;
      }else{
         my $tmp = LWP::Simple::get($args{-URL});
            $tmp = safely_decode($tmp);
            return $tmp;
      }    
   }
}


Change to,

Code: Select all
sub open_template_from_url {
   my %args = (
               -URL  => undef,
               @_,
             );
         
   if(!$args{-URL}){
      carp "no url passed! $!";
      return undef;
   }else{
      eval { require LWP::Simple };
      if($@){
         carp "LWP::Simple not installed! $!";
         return undef;
      }else{
                        use LWP::Simple qw/get $ua/;
                       $ua->agent("Dada Mail"); # or, whatever

         my $tmp = get($args{-URL});
              $tmp = safely_decode($tmp);
         return $tmp;
      }    
   }
}


I'll make this a little more flexible in the next release of Dada Mail,
User avatar
justin
 
Posts: 4581
Joined: Wed Feb 13, 2008 8:41 pm
Location: Denver, CO

Re: Can't assign an external template

Postby disonancias » Mon Mar 26, 2012 9:12 pm

Justin, I can't find the files to modify. You forgot to specify which one is the first; and regarding the second, I don't have a dada/DADA/Widgets folder.

If it helps, I'm using Pro Dada 4.9.1.
disonancias
 
Posts: 5
Joined: Sun Mar 25, 2012 9:01 pm

Re: Can't assign an external template

Postby justin » Wed Mar 28, 2012 8:13 pm

Justin, I can't find the files to modify. You forgot to specify which one is the first; and regarding the second, I don't have a dada/DADA/Widgets folder.


First one is the mail.cgi and then correct path is,

dada/DADA/Template/Widgets/HTML.pm (sorry about that)

Fixes are also here:

https://raw.github.com/justingit/dada-m ... a/mail.cgi

https://raw.github.com/justingit/dada-m ... te/HTML.pm
User avatar
justin
 
Posts: 4581
Joined: Wed Feb 13, 2008 8:41 pm
Location: Denver, CO

Re: Can't assign an external template

Postby disonancias » Fri Mar 30, 2012 9:22 am

It worked like a charm :)
Thank you very much!
disonancias
 
Posts: 5
Joined: Sun Mar 25, 2012 9:01 pm

Re: Can't assign an external template

Postby JohnA » Sat Jul 14, 2012 12:21 am

justin wrote:I think your webserver is blocking the calls Dada Mail is making to your site, because of the user agent. You can try hacking Dada Mail, to use a different user agent:

{snip}

I'll make this a little more flexible in the next release of Dada Mail,


Justin, did you make it easier to change Dada's user agent in v5? If so how is it done?
JohnA
 
Posts: 35
Joined: Wed May 26, 2010 11:36 am

Next

Return to Other! Integration

Who is online

Users browsing this forum: No registered users and 1 guest

Loading