Forum Replies Created
-
AuthorPosts
-
4michaelcolemanMember@hughc I’m not an expert, but what I have been doing is setting the grid for each field (piklist uses a 12 column grid). So if I want multiple fields on one line I would make sure the value equals 12.
For example if I wanted to fields next to each other and the end of each array I would put the follow…
‘columns’ => 6If I wanted the field to take up the complete space I would use…
‘columns’ => 12Not sure if this was what you were looking for, but it works nice for me.
4michaelcolemanMember@jason – yes it is.
piklist('field', array( 'type' => 'group', 'field' => 'summit_sponsor_silver_group', 'add_more' => true, 'description' => 'Add sponsors as needed', 'fields' => array( array( 'type' => 'text', 'field' => 'sponsor_silver_name', 'label' => 'Sponsor Name', 'required' => false, 'columns' => 12 ), array( 'type' => 'textarea', 'field' => 'sponsor_silver_overview', 'label' => 'Sponsor Overview', 'required' => false, 'attributes' => array( 'rows' => 8, 'class' => 'large-text', ), 'columns' => 12 ), array( 'type' => 'text', 'field' => 'sponsor_silver_url', 'label' => 'Sponsor URL', 'required' => false, 'columns' => 12 ), array( 'type' => 'file', 'field' => 'upload_basic', 'label' => __('Sponsor Logo', 'piklist'), 'description' => __('Image Size: 00px X 00px','piklist'), 'required' => false, 'options' => array( 'modal_title' => __('Add Logo', 'piklist'), 'button' => __('Add Logo', 'piklist'), ), 'columns' => 4 ), ), 'on_post_status' => array( 'value' => 'lock' ) ));
4michaelcolemanMember@jason so here is what I am doing and still get the “is empty” instead of the content. Even when there is content submitted in my post for the silver level.
<?php $silver = get_post_meta($post->ID, 'summit_sponsor_silver_group', true); ?> <?php if (empty($silver['sponsor_silver_name'])) : ?> <p>is empty</p> <?php else : ?> // FULL HTML Code <?php endif; ?>
4michaelcolemanMember@Jason hmmm… the issue is I don’t want anything to show if there isn’t a sponsor. Meaning I am trying to hide the whole segment if there isn’t a sponsor for this level. So it seems that if sponsor_silver_name is empty then do nothing, correct?
4michaelcolemanMemberArray ( [0] => Array ( [sponsor_silver_name] => TSI Co [sponsor_silver_overview] => Sample text for this sponsor [sponsor_silver_url] => http://www.logo.com [upload_basic] => Array ( [0] => 10412 ) ) )
4michaelcolemanMember@Jason Here is the output of print
Array ( [0] => Array ( [sponsor_silver_name] => TSI Co [sponsor_silver_overview] => Sample text for this sponsor [sponsor_silver_url] => http://www.logo.com [upload_basic] => Array ( [0] => 10412 ) ) )
4michaelcolemanMember@Jason here are examples of what it looks like on the page for both instances (attached). As you can see the html is still present even when there is no content. Im not getting the version where I am simply writing the “p” tag with this is empty. So not sure why this is not taking the “else” call.
Attachments:
You must be logged in to view attached files.
4michaelcolemanMember@Jason Went with option one. Simply because I wanted to customize the data points and modify the styles of the output. Will use option two for some other things that I am working on.
Thanks
Michael
4michaelcolemanMemberOK, This is starting to do what I want, but what was not happening is listing the sponsors under each level. So I added back the original loop through the groups and its just listing all them each time. How do I go about looping through each segment and only showing the sponsors for each.
Current Code
<?php $groups = get_post_meta($post->ID, 'summit_sponsor_group', true); foreach($groups as $group): ?> <?php if ( 'Platinum' === $group['sponsor_level'] ): ?> <div class="col-xs-12"> <h3><span>Platinum</span> Sponsors</h3> </div> <?php foreach($groups as $post): ?> <div class="col-xs-12 platinum"> <div class="col-xs-12 col-sm-3"> <a href="<?php echo $post['sponsor_url']; ?>" target="_blank"> <?php $image_ids = $post['upload_basic']; ?> <?php foreach ($image_ids as $image): ?> <img class="img-responsive" src="<?php echo wp_get_attachment_url($image); ?>" width="200" height="200"> <?php endforeach; ?> </a> </div> <div class="col-xs-12 col-sm-9"> <h4><?php echo $post['sponsor_name']; ?></h4> <p><?php echo $post['sponsor_overview']; ?></p> <p><?php echo $post['sponsor_level']; ?></p> </div> <div class="col-xs-2 pull-right platinum-link"> <a href="<?php echo $post['sponsor_url']; ?>" target="_blank"><?php echo $post['sponsor_name']; ?> <i class="fa fa-angle-right"></i></a> </div> </div> <?php endforeach; ?> <?php elseif ( 'Gold' === $group['sponsor_level'] ): ?> <div class="col-xs-12"> <h3><span>Gold</span> Sponsors</h3> </div> <?php foreach($groups as $post): ?> <div class="col-xs-12 gold"> <div class="col-xs-12 col-sm-3"> <a href="<?php echo $post['sponsor_url']; ?>" target="_blank"> <?php $image_ids = $post['upload_basic']; ?> <?php foreach ($image_ids as $image): ?> <img class="img-responsive" src="<?php echo wp_get_attachment_url($image); ?>" width="200" height="200"> <?php endforeach; ?> </a> </div> <div class="col-xs-12 col-sm-9"> <h4><?php echo $post['sponsor_name']; ?></h4> <p><?php echo $post['sponsor_overview']; ?></p> <p><?php echo $post['sponsor_level']; ?></p> </div> <div class="col-xs-2 pull-right platinum-link"> <a href="<?php echo $post['sponsor_url']; ?>" target="_blank"><?php echo $post['sponsor_name']; ?> <i class="fa fa-angle-right"></i></a> </div> </div> <?php endforeach; ?> <?php else : ?> <div class="col-xs-12"> <h3><span>Silver</span> Sponsors</h3> </div> <?php foreach($groups as $post): ?> <div class="col-xs-12 silver"> <div class="col-xs-12 col-sm-3"> <a href="<?php echo $post['sponsor_url']; ?>" target="_blank"> <?php $image_ids = $post['upload_basic']; ?> <?php foreach ($image_ids as $image): ?> <img class="img-responsive" src="<?php echo wp_get_attachment_url($image); ?>" width="200" height="200"> <?php endforeach; ?> </a> </div> <div class="col-xs-12 col-sm-9"> <h4><?php echo $post['sponsor_name']; ?></h4> <p><?php echo $post['sponsor_overview']; ?></p> <p><?php echo $post['sponsor_level']; ?></p> </div> <div class="col-xs-2 pull-right platinum-link"> <a href="<?php echo $post['sponsor_url']; ?>" target="_blank"><?php echo $post['sponsor_name']; ?> <i class="fa fa-angle-right"></i></a> </div> </div> <?php endforeach; ?> <?php endif; ?> <?php endforeach; ?>
4michaelcolemanMemberThis is the complete piklist group.
<?php /* Title: Sponsors Post Type: piklist_sikka_summit Order: 100 */ piklist('field', array( 'type' => 'group', 'field' => 'summit_sponsor_group', 'add_more' => true, 'description' => 'Add sponsors as needed', 'fields' => array( array( 'type' => 'text', 'field' => 'sponsor_name', 'label' => 'Sponsor Name', 'required' => true, 'columns' => 12 ), array( 'type' => 'textarea', 'field' => 'sponsor_overview', 'label' => 'Sponsor Overview', 'required' => true, 'attributes' => array( 'rows' => 8, 'class' => 'large-text', ), 'columns' => 12 ), array( 'type' => 'text', 'field' => 'sponsor_url', 'label' => 'Sponsor URL', 'required' => true, 'columns' => 12 ), array( 'type' => 'select', 'field' => 'sponsor_level', 'label' => 'Sponsor Level', 'required' => true, 'attributes' => array( 'class' => 'text' ), 'choices' => array( '' => '-- Select --', 'Platinum' => 'Platinum', 'Gold' => 'Gold', 'Silver' => 'Silver', ), 'columns' => 4 ), array( 'type' => 'file', 'field' => 'upload_basic', 'label' => __('Sponsor Logo', 'piklist'), 'description' => __('Image Size: 00px X 00px','piklist'), 'required' => true, 'options' => array( 'modal_title' => __('Add Logo', 'piklist'), 'button' => __('Add Logo', 'piklist'), ), 'columns' => 4 ), ), 'on_post_status' => array( 'value' => 'lock' ) )); ?>
4michaelcolemanMember@Jason That’s because I want to pull in all the data from the piklist group, and then display the listings by the sponsor_level for each type
4michaelcolemanMember@steve do I still keep this line in the php?
$sponsors = get_post_meta($post->ID, 'summit_sponsor_group', true);For some reason when I try and add the example you provided
$levels = array( 'Platinum' ,'Gold' ,'Silver' );It has a problem with ‘Gold’ and doesn’t go any further.
4michaelcolemanMemberWith what I’m currently doing it is not giving me the results I’m looking for. All the listings are coming out at the end under of the loop under Silver Sponsors, with just that header.
4michaelcolemanMemberHere is what I have been playing with…
<?php $sponsors = get_post_meta($post->ID, 'summit_sponsor_group', true); if ($sponsors == "Platinum"): ?> <div class="col-xs-12"> <h3><span>Platinum</span> Sponsors</h3> </div> <?php foreach($sponsors as $post): ?> <div class="col-xs-12 platinum"> <div class="col-xs-12 col-sm-3"> <a href="http://www.tsico.com/" target="_blank"> <?php $image_ids = $post['upload_basic']; ?> <?php foreach ($image_ids as $image): ?> <img class="img-responsive" src="<?php echo wp_get_attachment_url($image); ?>" width="200" height="200"> <?php endforeach; ?> </a> </div> <div class="col-xs-12 col-sm-9"> <p><?php echo $post['sponsor_overview']; ?></p> <p><?php echo $post['sponsor_level']; ?></p> </div> <div class="col-xs-2 pull-right platinum-link"> <a href="http://www.tsico.com/" target="_blank"><?php echo $post['sponsor_name']; ?> <i class="fa fa-angle-right"></i></a> </div> </div> <?php endforeach; ?> <?php elseif($sponsors == "Gold"): ?> <div class="col-xs-12"> <h3><span>Gold</span> Sponsors</h3> </div> <?php foreach($sponsors as $post): ?> <div class="col-xs-12 gold"> <div class="col-xs-12 col-sm-3"> <a href="http://www.tsico.com/" target="_blank"> <?php $image_ids = $post['upload_basic']; ?> <?php foreach ($image_ids as $image): ?> <img class="img-responsive" src="<?php echo wp_get_attachment_url($image); ?>" width="200" height="200"> <?php endforeach; ?> </a> </div> <div class="col-xs-12 col-sm-9"> <p><?php echo $post['sponsor_overview']; ?></p> <p><?php echo $post['sponsor_level']; ?></p> </div> <div class="col-xs-2 pull-right platinum-link"> <a href="http://www.tsico.com/" target="_blank"><?php echo $post['sponsor_name']; ?> <i class="fa fa-angle-right"></i></a> </div> </div> <?php endforeach; ?> <?php else : ?> <div class="col-xs-12"> <h3><span>Silver</span> Sponsors</h3> </div> <?php foreach($sponsors as $post): ?> <div class="col-xs-12 silver"> <div class="col-xs-12 col-sm-3"> <a href="http://www.tsico.com/" target="_blank"> <?php $image_ids = $post['upload_basic']; ?> <?php foreach ($image_ids as $image): ?> <img class="img-responsive" src="<?php echo wp_get_attachment_url($image); ?>" width="200" height="200"> <?php endforeach; ?> </a> </div> <div class="col-xs-12 col-sm-9"> <p><?php echo $post['sponsor_overview']; ?></p> <p><?php echo $post['sponsor_level']; ?></p> </div> <div class="col-xs-2 pull-right platinum-link"> <a href="http://www.tsico.com/" target="_blank"><?php echo $post['sponsor_name']; ?> <i class="fa fa-angle-right"></i></a> </div> </div> <?php endforeach; ?> <?php wp_reset_query(); ?> <?php endif; ?>
4michaelcolemanMemberLooping through and pulling the data is not the problem. What I’m trying to do is separate the data by level in different lists, which will be formatted differently.
Hence, will pull all the data for Platinum, and just logo and name for Gold and Silver (with URL). Want to do a full width for Platinum, and then break up Gold and Silver side by side in two columns with a header above each. So looking to match by level for each select item.
-
AuthorPosts