Forum

Thread tagged as: Question, Suggestions, Discussion

I'm not sure if I understood completely but I moved the steps to the top of my code. I deleted the cookie and have also bene logging in and out and using different browsers - but still no joy.

It will only show me the 'Application Form' template/region

<?php include('../something/runtime.php'); ?>
<?php $steps = [
  [ 'application-received' => 'Application Received' ],
  [ 'application-pending' => 'Application Pending' ],
  [ 'application-rejected' => 'Application Rejected' ],
  [ 'application-accepted' => 'Application Accepted' ],
  [ 'payment-pending' => 'Payment Pending' ],
  [ 'everything-complete' => 'Everything Complete' ],
  ];
?>
<?php perch_content_create('Application Received', array(
    'edit-mode' => 'listdetail',
    'template' => 'application_message_application_received.html',
  ));
?>
<?php perch_content_create('Application Pending', array(
    'edit-mode' => 'listdetail',
    'template' => 'application_message_application_pending.html',
  ));
?>
<?php perch_content_create('Application Rejected', array(
    'edit-mode' => 'listdetail',
    'template' => 'application_message_application_rejected.html',
  ));
?>
<?php perch_content_create('Application Accepted', array(
    'edit-mode' => 'listdetail',
    'template' => 'application_message_application_accepted.html',
  ));
?>
<?php perch_content_create('Payment Pending', array(
    'edit-mode' => 'listdetail',
    'template' => 'application_message_payment_pending.html',
  ));
?>
<?php perch_content_create('Everything Complete', array(
    'edit-mode' => 'listdetail',
    'template' => 'application_message_everything_complete.html',
  ));
?>
<?php perch_content_create('Application Form', array(
    'edit-mode' => 'listdetail',
    'template' => 'application_form.html',
  ));
?>
<?php perch_layout('global.header'); ?>
<section class="content no-header">
  <div class="container">
    <div class="row">
      <?php
        foreach($steps as $tag => $region) {
          $chosen_region = 'Application Form';
        if (perch_member_has_tag($tag)) $chosen_region = $region;
          }
        perch_content($chosen_region);
      ?>
    </div>
  </div>
</section>

<?php perch_layout('global.footer'); ?>
</body>
</html>

replace this

<?php
foreach($steps as $tag => $region) {
$chosen_region = 'Application Form';
if (perch_member_has_tag($tag)) $chosen_region = $region;
}
perch_content($chosen_region);
?>

with this

<?php
foreach($steps as $tag => $region) {
$chosen_region = 'Application Form';
if (perch_member_has_tag($tag)) {
    PerchUtil::debug('FOUND TAG: '.$tag);
    $chosen_region = $region;
}else{
    PerchUtil::debug('NO TAG: '.$tag);
}
perch_content($chosen_region);
?>

Check your Debug and whats going on?

Hmmm

I'm getting

Parse error: syntax error, unexpected end of file in /var/sites/d/dev.amso.online/public_html/learning-community/application.php on line 68

But I cant see anything wrong with the code - I don't even have a line 68

<?php include('../something/runtime.php'); ?>
<?php perch_content_create('Application Received', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_received.html',
));
?>
<?php perch_content_create('Application Pending', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_pending.html',
));
?>
<?php perch_content_create('Application Rejected', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_rejected.html',
));
?>
<?php perch_content_create('Application Accepted', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_accepted.html',
));
?>
<?php perch_content_create('Payment Pending', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_payment_pending.html',
));
?>
<?php perch_content_create('Everything Complete', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_everything_complete.html',
));
?>
<?php perch_content_create('Application Form', array(
'edit-mode' => 'listdetail',
'template' => 'application_form.html',
));
?>
<?php perch_layout('global.header'); ?>
<section class="content no-header">
  <div class="container">
    <div class="row">
      <?php
      $steps = [
      [ 'application-received' => 'Application Received' ],
      [ 'application-pending' => 'Application Pending' ],
      [ 'application-rejected' => 'Application Rejected' ],
      [ 'application-accepted' => 'Application Accepted' ],
      [ 'payment-pending' => 'Payment Pending' ],
      [ 'everything-complete' => 'Everything Complete' ],
      ];
      ?>
      <?php
      foreach($steps as $tag => $region) {
      $chosen_region = 'Application Form';
      if (perch_member_has_tag($tag)) {
        PerchUtil::debug('FOUND TAG: '.$tag);
        $chosen_region = $region;
      }else{
       PerchUtil::debug('NO TAG: '.$tag);
      }
      perch_content($chosen_region);?>
    </div>
  </div>
</section>
<?php perch_layout('global.footer'); ?>
</body>
</html>
<?php PerchUtil::output_debug(); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

That sounds like a bracket or brace set left open.

Sorry my bad. Was a missing }

Ok so now i'm getting the following in my debug:

Debug Message - Perch 3.0.1
[1] SELECT * FROM perch2_members_sessions WHERE sessionID='c92b1f23e9dc571b83135bd97acf16e6ba05b8ce' AND sessionHttpFootprint='d14cd54ac70be985706a5b10946fd141a936e5de' AND sessionExpires>'2017-04-10 18:51:02' LIMIT 1
User is logged in
[1] SELECT * FROM perch2_pages WHERE pagePath='/learning-community/application.php' LIMIT 1
[19] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/learning-community/application.php' OR regionPage='*' ORDER BY regionPage DESC
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
[11] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageHidden=0 ORDER BY pageTreePosition ASC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/learning-community/application.php' LIMIT 1
[2] SELECT pageID FROM perch2_pages WHERE pageTreePosition IN ('000-009-001', '000-009', '000') ORDER BY pageTreePosition DESC
[5] Using template: /templates/navigation/item.html
NO TAG: 0
NO TAG: 1
NO TAG: 2
NO TAG: 3
NO TAG: 4
NO TAG: 5

Any ideas from looking at my debug output where I'm going wrong?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What's not working?

My steps with Member Tags.

No matter what tag I'm applying to a member account. It will only ever show me the content for 'Application Form'.

I want it to for example: If a member has the tag 'application-received' to see the content for 'Application Received' and that content only. I want the Application Form to be hidden unless the member has no tags.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you sure your logic is correct and this is a Perch issue?

I think it's a Perch issue as I'm using the code that you recommended along with some content areas that are being created:

Here's the content areas

<?php perch_content_create('Application Received', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_received.html',
));
?>
<?php perch_content_create('Application Pending', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_pending.html',
));
?>
<?php perch_content_create('Application Rejected', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_rejected.html',
));
?>
<?php perch_content_create('Application Accepted', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_application_accepted.html',
));
?>
<?php perch_content_create('Payment Pending', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_payment_pending.html',
));
?>
<?php perch_content_create('Everything Complete', array(
'edit-mode' => 'listdetail',
'template' => 'application_message_everything_complete.html',
));
?>
<?php perch_content_create('Application Form', array(
'edit-mode' => 'listdetail',
'template' => 'application_form.html',
));
?>

and here's the code that you recommended


<?php $steps = [ [ 'application-received' => 'Application Received' ], [ 'application-pending' => 'Application Pending' ], [ 'application-rejected' => 'Application Rejected' ], [ 'application-accepted' => 'Application Accepted' ], [ 'payment-pending' => 'Payment Pending' ], [ 'everything-complete' => 'Everything Complete' ], ]; foreach($steps as $tag => $region) { $chosen_region = 'Application Form'; if (perch_member_has_tag($tag)) $chosen_region = $region; } perch_content($chosen_region); ?>
Drew McLellan

Drew McLellan 2638 points
Perch Support

I was simply trying to help with your question - this isn't the software you've paid for, it's just me trying to be helpful.

Have the regions been created?

Where are you applying the tags?

Oh I know that Drew - I really appreciate your help. I'm sorry if I came across rude there at all - That wasn't my intention

Yes I have created all of the regions in Perch Admin and assigned content and I am applying the tags on the individual member profile page - also in Perch Admin - see here

I'm assuming the problem lies here:

 foreach($steps as $tag => $region) {
        $chosen_region = 'Application Form';
        if (perch_member_has_tag($tag)) $chosen_region = $region;
        }
        perch_content($chosen_region);

and it's not picking up any tags as the debug shows:

NO TAG: 0
NO TAG: 1
NO TAG: 2
NO TAG: 3
NO TAG: 4
NO TAG: 5

If I manually change the chosen_region to one of the steps then the page displays what it should be showing for that region - so I know that's working.

There must be a problem with my foreach statement - Could you please check it to see if you can see where I'm going wrong?

Drew McLellan

Drew McLellan 2638 points
Perch Support

When are you assigning the tags?

Hi Drew,

Tags are just being assigned manually at various times.. Nothing on the site/system adds the tags for my user.

What I'm trying to achieve is an application form journey. For example:

  1. User fills out application form on application.php

  2. Once my client has seen the submitted form entry they will add the Tag 'application-received' to the members account in Perch Admin. This would then hide the application form from application.php and instead display a message saying that the application has been received along with some other stuff

  3. Once they have reviewed the application they will go back to that members account and add either 'application-accepted' 'application-rejected' etc and I want to show the content that is relevant to each of these tags.

Drew McLellan

Drew McLellan 2638 points
Perch Support

This is wrong - you keep setting the region back on every iteration:

foreach($steps as $tag => $region) {
        $chosen_region = 'Application Form';
        if (perch_member_has_tag($tag)) $chosen_region = $region;
}
perch_content($chosen_region);

should be:

$chosen_region = 'Application Form';
foreach($steps as $tag => $region) {
        if (perch_member_has_tag($tag)) $chosen_region = $region;
}
perch_content($chosen_region);

Thanks Drew - that worked.

Massively appreciate your help on this