Forum

Thread tagged as: Question, Runway, MailChimp

Problem displaying list archives on Perch Runway site

I’ve setup the MailChimp app and successfully integrated it with a contact form - it works great.

I’d like to be able to display an archive list of email campaigns on my website, but I can’t get it to work?

I’ve Moved the MailChimp folder into templates > pages and removed the perch runtime line from each page template (campaign.php, campaigns.php and subscribe.php).

I've setup two pages. /campaign and /campaigns using the page templates below:

campaigns.php the page displays, but no archives are listed?

    <?php
   // Include the header. You can find this in templates/layouts/global
   perch_layout('global/header', [
   'body-class' => 'campaigns',
   ]);

   // An editable content region
   perch_content('Main heading');

// Main navigation
perch_pages_navigation([
'levels'=>1
]);

   //show an archive on a page
   perch_mailchimp_campaigns();

   // Include the footer. You can find this in templates/layouts/global
perch_layout('global/footer’);

campaign.php

  <?php
     perch_mailchimp_campaign_content(perch_get('s'));

I’ve changed the location of the detail page under MailChimp settings in the Perch control panel:

   //Campaign archive page path
    /campaigns

Back on the MailChimp website I’ve made sure campaigns are marked as public.

  • There are no error PHP logs
  • Debug is on and there are no errors on /campaigns
  • I’m sure the MailChimp app is configured right because the contact form integration works great.

Are there any gotchas that I might be missing?

Stephen Meehan

Stephen Meehan 4 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you see your campaigns in the control panel?

I can see all the sent campaigns on my /campaigns page, using perch_mailchimp_campaigns(); This bit works :)

I'm having problems viewing a single campaign though.

This is how I've got my pages setup:

  • /campaigns lists all the sent campaigns - using campaign_list.html template
  • /campaign is supposed to show the selected campaign - but it doesn't

The template for /campaign (campaign.php) only has this in it, I've made sure there's no whitespace.

  <?php
      // include('../perch/runtime.php');
      // removed runtime.php because I'm using Runway
     perch_mailchimp_campaign_content(perch_get('s'));
     ?>

I’ve changed the location of the detail page under MailChimp settings in the Perch control panel to:

   /campaign

When I click a link on the archive list (on /campaigns) it takes me to /campaign and the page is blank, apart for the debug message.

This is the debug message on that page:

 Debug Message
 SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN      perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC
 Using master page: /templates/pages/mailchimp/campaign.php
 Page arguments:
 SELECT * FROM perch2_mailchimp_campaigns WHERE campaignSlug='' LIMIT 1
 Time: 0.0478
 Memory: 4.6482

All the href in the archive list look like this:

     <a href="/campaign">Winter Newsletter 2013</a>

I'd of expected each one to have a unique URL? Maybe something to do with campaignSlug?

There's no PHP errors logged.

Hi

I figured out the URL in MailChimp settings in the Perch control panel needs to have {campaignSlug} on the end :

/campaign/{campaignSlug}

This adds the campaign slug to each href in the archive list.

/campaign/28-jul-2014-summer-newsletter-2014
// This 404s

When I click any of the links I get a 404. I know I need to add a URL pattern, but I can't find any documentation for MailChimp URL Patterns?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You don't need specific documentation for creating the route - it's the same as anything else.

This should work:

campaign/[slug:s]

Bingo! Thanks Drew.