Support has been upgraded!
The Support Forum is closed. Not to worry! Providing the top quality support you expect and we're known for will continue! We're not ending support, just changing where you submit requests. This will provide you with the best experience possible.
Premium Support
Have you purchased an addon for Connections such as one of our premium templates or extensions with a valid license and you need help?
Please open a Support Ticket in your user account.
Free Support
Are you using the free Connections plugin? Don't worry, you are still very important to us! We are still providing you with the same high quality support that we're known for.
Please open a new support topic in the WordPress support forums for Connections.
Tagged: 8.11, custom fields, template
- This topic has 3 replies, 2 voices, and was last updated 5 years, 10 months ago by
Steven Zahm.
-
AuthorPosts
-
02/10/2018 at 4:51 pm #451156
Gregory Godsey
GuestI know I am asking a lot, but if you could help, I would greatly appreciate it.
I added a few fields with Code Snippet. You helped me with that and it worked great on the back end. However, I am now having issues with adding it to the theme so that it is visible on the front end. Here is my card.php:
<?php // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) { exit; } /** * @var cnOutput $entry */ $style = array( 'background-color' => '#FFF', 'border' => $atts['border_width'] . 'px solid ' . $atts['border_color'], 'border-radius' => $atts['border_radius'] . 'px', 'color' => '#000', 'margin' => '8px 0', 'padding' => '10px', 'position' => 'relative', ); $bio = $entry->getBio(); $notes = $entry->getNotes(); ?> <div class="cn-entry" <?php echo cnHTML::attribute( 'style', $style ); ?>> <div class="cn-left" style="width:49%; float:<?php echo is_rtl() ? 'right' : 'left'; ?>"> <?php if ( 'none' !== $atts['image_type'] ) { $entry->getImage( array( 'image' => $atts['image_type'], 'width' => $atts['image_width'], 'height' => $atts['image_height'], 'zc' => $atts['image_crop_mode'], 'fallback' => array( 'type' => $atts['image_fallback'] ? 'block' : 'none', 'string' => $atts['image_fallback_string'], ), ) ); } ?> <div style="clear:both;"></div> <div style="margin-bottom: 10px;"> <div style="font-size:larger;font-variant: small-caps"><?php echo $entry->getNameBlock( array( 'format' => $atts['name_format'] ) ); ?></div> <?php if ( $atts['show_title'] ) $entry->getTitleBlock(); if ( $atts['show_org'] || $atts['show_dept'] ) { $entry->getOrgUnitBlock( array( 'show_org' => $atts['show_org'], 'show_dept' => $atts['show_dept'], ) ); } if ( $atts['show_contact_name'] ) { $entry->getContactNameBlock( array( 'format' => $atts['contact_name_format'], //'label' => $atts['str_contact_label'] ) ); } ?> </div> </div> <div class="cn-right" style="text-align: right;"> <?php if ( $atts['show_addresses'] ) $entry->getAddressBlock( array( 'format' => $atts['address_format'] , 'type' => $atts['address_types'] ) ); if ( $atts['show_family'] )$entry->getFamilyMemberBlock(); if ( $atts['show_phone_numbers'] ) $entry->getPhoneNumberBlock( array( 'format' => $atts['phone_format'] , 'type' => $atts['phone_types'] ) ); if ( $atts['show_email'] ) $entry->getEmailAddressBlock( array( 'format' => $atts['email_format'] , 'type' => $atts['email_types'] ) ); if ( $atts['show_im'] ) $entry->getImBlock(); if ( $atts['show_dates'] ) $entry->getDateBlock( array( 'format' => $atts['date_format'], 'type' => $atts['date_types'] ) ); if ( $atts['show_links'] ) $entry->getLinkBlock( array( 'format' => $atts['link_format'], 'type' => $atts['link_types'] ) ); if ( $atts['show_social_media'] ) $entry->getSocialMediaBlock(); ?> </div> <div class="cn-left" style="text-align: left;"> <?php echo "<h4>Ordination Info</h4>"; $datepicker = $entry->getMeta( array( 'key' => 'deacon_ordo_date', 'single' => TRUE ) ); $text = $entry->getMeta( array( 'key' => 'deacon_ordain_bishop', 'single' => TRUE ) ); if ( ! empty( $datepicker ) && ! empty( $text ) ) { $dateb = cnDate::createFromFormat( 'm/d/Y', $datepicker )->format( 'j F Y' ); echo 'Deacon Ordination: ' . $dateb . ' by ' . $text . '
'; } ?> <?php $datepicker = $entry->getMeta( array( 'key' => 'priest_ordo_date', 'single' => TRUE ) ); $text = $entry->getMeta( array( 'key' => 'priest_ordain_bishop', 'single' => TRUE ) ); if ( ! empty( $datepicker ) && ! empty( $text ) ) { $datea = cnDate::createFromFormat( 'm/d/Y', $datepicker )->format( 'j F Y' ); echo 'Priest Ordination: ' . $datea . ' by ' . $text . '
'; } ?> <?php $datepicker = $entry->getMeta( array( 'key' => 'bishop_ordo_date', 'single' => TRUE ) ); $text = $entry->getMeta( array( 'key' => 'bishop_ordain_bishop', 'single' => TRUE ) ); if ( ! empty( $datepicker ) && ! empty( $text ) ) { $date = cnDate::createFromFormat( 'm/d/Y', $datepicker )->format( 'j F Y' ); echo 'Bishop Consecration: ' . $date . ' by ' . $text . '<p/>'; } ?> </div> <div style="clear:both"></div> <?php if ( $atts['show_bio'] && 0 < strlen( $bio ) ) { $entry->getBioBlock( array( 'before' => '<h4>' . esc_html__( 'Biographical Info', 'connections' ) . '</h4>' . PHP_EOL, 'after' => '<div class="cn-clear"></div>', ) ); } if ( $atts['show_notes'] && 0 < strlen( $notes ) ) { $entry->getNotesBlock( array( 'before' => '<h4>' . esc_html__( 'Notes', 'connections' ) . '</h4>' . PHP_EOL, 'after' => '<div class="cn-clear"></div>', ) ); } ?> <div class="cn-meta" style="margin-top: 6px"> <?php $entry->getContentBlock( $atts['content'], $atts, $template ); ?> </div> <div class="cn-clear" style="display:table;width:100%;"> <div style="display:table-cell;vertical-align:middle;"> <?php if ( $atts['show_categories'] ) { $entry->getCategoryBlock( array( 'separator' => ', ' ) ); } ?> </div> <div style="display:table-cell;text-align:right;vertical-align:middle;"> <?php if ( $atts['show_last_updated'] ) { cnTemplatePart::updated( array( 'timestamp' => $entry->getUnixTimeStamp(), 'style' => array( 'font-size' => '10px', 'font-variant' => 'small-caps', 'margin-right' => '10px', ) ) ); } if ( $atts['show_return_to_top'] ) { cnTemplatePart::returnToTop(); } ?> </div> </div> </div>However, when activated, this is what I see on the front end:
What am I doing wrong? Why is adding those fields removing all the other data? The fields I added show up, but none of the other data.
Thanks for your patience and help.
Bishop Gregory Godsey
02/12/2018 at 9:41 am #451300Steven Zahm
Keymaster@ Gregory
Looking at the code, nothing jumps out to me as fatally wrong… My suggestion, revert back to the original code for the template and add pieces of you code back in until you can isolate the error.
For example, start with adding:
echo "<h4>Ordination Info</h4>";
After you verify everything still works, then add:
$datepicker = $entry->getMeta( array( 'key' => 'deacon_ordo_date', 'single' => TRUE, ) ); $text = $entry->getMeta( array( 'key' => 'deacon_ordain_bishop', 'single' => TRUE, ) );
Again, verify that everything still works, then add:
if ( ! empty( $datepicker ) && ! empty( $text ) ) { $dateb = cnDate::createFromFormat( 'm/d/Y', $datepicker )->format( 'j F Y' ); echo 'Deacon Ordination: ' . $dateb . ' by ' . $text . ''; }
Rinse, wash, repeat… Hope this helps, let me know.
02/13/2018 at 3:34 am #451497Gregory Godsey
GuestThank you so much for your help! I was able to figure out that it was not the code above but an old template file that was causing the problem.
All solved! Thanks again for the wonderful plugin and the support!
Bishop Greg
02/13/2018 at 9:03 am #451533Steven Zahm
Keymaster@ Gregory
Good to hear you have this sorted!
-
AuthorPosts
You cannot reply to this support topic. Please open your own support topic.