Support

Account

Forum Replies Created

  • That worked! Those types of fields don’t seem to work well on a foreach loop. Restructuring the loop was my next plan of attack. Appreciate you sticking with this. Thanks Mediawerk, have a great day!

  • Thanks Mediawerk. I had originally tried the checkbox which did not work so I tried true/false. I just tried the radio button but that has no affect either. I can’t get the class in the li tag to appear. Any other suggestions?

  • GOT IT!!!!! Yay, finally, thanks so much for your help! I can’t thank you enough. If you can get me your email I will Quickly a beer or two 🙂

    <div class="quick-link-sidebar">
    
    	<?php if( have_rows('pro_resource_links') ):
    
    	$h1 = true; // add a simple boolean set to true ?>
    
    	<?php  	// loop through the rows of data
    			while ( have_rows('pro_resource_links') ) : the_row(); ?>
    
    			    <?php $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    														
    			     	<h1>Quicklinks</h1>
    
    			     	<ul class="resource-links">
    
    			     	<?php $h1 = false; //now $h1 goes before this "if" condition closing bracket and it's set to false to limit the conditional only to the first link ?>
    				    <?php } ?>
    
    				    
    					<?php if ( $quick_link_column == "yes" ) { // Continue with all the links ?>						
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url') ;?><?php the_sub_field('pro_resource_download') ;?>"><?php the_sub_field('pro_resource_link_name'); ?></a>
    				     	</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    					     
    					<?php endwhile; ?>
    					<?php wp_reset_postdata(); ?>
          
    					</ul>
    		
    	<?php endif; ?>
    
    </div><!-- end Quicklinks Sidebar -->
  • You are a saint for sticking with this. I hope I can figure out a way to buy you a beer after this…I tried your code but made modifications to fit my revised custom fields. Now there is just one section of Resourse Links instead of URLs and Downloads. And I changed the checkbox to true/false. It seems cleaner now. Your code modification are working better. The only thing is when there are more that one entry, the subsequent entries do not display within the UL tag. I am attaching a screenshot which also shows the html result. One thing I did not take into account… when all links are Quicklinks, the random header remains in the main column.

    Latest revision (ignore new section in main column):

    <div class="quick-link-sidebar">	
    
    	<?php if( have_rows('pro_resource_links') ): ?>
    	
      			<?php 
    				$h1 = true; // add a simple boolean set to true
    				// loop through the rows of data
    			    while ( have_rows('pro_resource_links') ) : the_row(); ?>
    
    			    <?php $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == true ) { ?>
    
    					<h1>Quicklinks</h1>
    
    					<ul class="resource-links">
    
    					<?php $h1 = false; //now $h1 goes before this "if" condition closing bracket and it's set to false to limit the conditional only to the first link ?>
    				    <?php } ?>
    
    				    
    					<?php if ( $quick_link_column == true ) { // Continue with all the links ?>						
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url') ;?><?php the_sub_field('pro_resource_download') ;?>"><?php the_sub_field('pro_resource_link_name'); ?></a>
    				     	</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    
    			        </ul>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    
    			
    			<?php if ($h1) { } else { ?>
                               </ul>
    			<?php } ?>
    			
    			<?php endif; ?>
    
    </div><!-- end Quicklinks Sidebar -->
  • UPDATE—I changed my checkboxes with yes/no options (it was actually a radio group) to true/false and changed ==”yes” to ==true and I get the same result as the screenshots I uploaded. On to plan 2…

  • Hi Drivebass,

    Still not there. I took some screen shots of the results. I also took a screen shot of my ACF setup in admin.

    1. For starters nothing is showing up ad all from the Resource download section. Blank sidebar

    2.The Resource URL entries seem to work at first but only the first entry 9see screenshot). The second entry appears to add the head above each li entry (see screenshot.

    My strategy for the day is to modify the ACF checkbox field from checkboxes with yes/no options to a single true/false checkbox and continue to work with your code. Maybe the checkbox files with yes/no options is overcomplicated. (as well as unnecessary because it really is just a true/false)

    Also, Im considering combining the files groups so the user can add either a url or a download within the same entry eliminating the need for 2 sections. I suppose the division of URLS vs. Downloads is unnecessary-or it can be reordered as needed. Then I don’t have to deal with the heading appearing twice- once above each section.

    Thanks again for helping me with this and your quick responses. I hope to figure this out soon but please let me know if you have any other ideas!

  • Shoot I meant to say the first checked resource URL entry appears twice, not resource download.

  • Sorry, here is the correct code as I have it right now, the top post had an error. I also for got to mention while the Quicklink heading does not appear with a Resource Download entry, also the Resource download entry appears twice when chick link is checked.

    <div class="quick-link-sidebar">	
    
    	<?php if( have_rows('pro_resource_url') || have_rows('pro_resource_download') ): ?>
    	
      			<?php 
    				$h1 = true; // add a simple boolean set to true
    				// loop through the rows of data
    			    while ( have_rows('pro_resource_url') ) : the_row(); ?>
    
    			    <?php $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    
    					<ul class="resource-links">
    
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    				        </li>
    
    				    <?php } ?>
    
    				    <?php $h1 = false; //now set the $h1 to false so only it doesn't display multiple times ?>
    					<?php if ( $quick_link_column == "yes" ) { // Continue with the other links ?>						
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    				     	</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    
    			        </ul>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    
    			<?php  	// loop through the rows of data
    			    while ( have_rows('pro_resource_download') ) : the_row();
    					$h1 = true; // add a simple boolean set to true ?>
    
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    					
    					<ul class="resource-links">
    														
    			     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    			     		<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    			        </li>
    
    			        <?php } ?>
    
    			        <?php $h1 = false; ?>
    					<?php if ( $quick_link_column == "yes" ) { // Continue with the other links ?>	
    					<li class="<?php echo the_sub_field('indy_content'); ?>">
    							<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    					</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    			<?php if ($h1) {//do nothing
    			} else { 
    			} ?>
    			</ul>
    			<?php endif; ?>
    
    </div><!-- end Quicklinks Sidebar -->
  • Hi Drivebass,

    I was able to fix the syntax problem by relocating the offending curly bracket. My “fix” however may be messing up your solution. It doesn’t seem to work when only a resource download entry exists. Still futzing with it… Below is what i have so far

    
    <div class="quick-link-sidebar">	
    
    	<?php if( have_rows('pro_resource_url') || have_rows('pro_resource_download') ): ?>
    	
      			<?php 
    				$h1 = true; // add a simple boolean set to true
    				// loop through the rows of data
    			    while ( have_rows('pro_resource_url') ) : the_row(); ?>
    
    			    <?php $quick_link_column = get_sub_field('quick_link');  ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    
    					<ul class="resource-links">
    
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    				        </li>
    
    				    <?php } ?>
    
    				    <?php $h1 = false; //now set the $h1 to false so only it doesn't display multiple times ?>
    					<?php if ( $quick_link_column == "yes" ) { // Continue with the other links ?>						
    				     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    				     		<a href="<?php the_sub_field('pro_url'); ;?>"><?php the_sub_field('pro_resource_url_name'); ?></a>
    				     	</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    
    			        </ul>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    
    			<?php  	// loop through the rows of data
    			    while ( have_rows('pro_resource_download') ) : the_row(); ?>
    					
    					<?php if ( $h1 && $quick_link_column == "yes" ) { ?>
    
    					<h1>Quicklinks</h1>
    					
    					<ul class="resource-links">
    														
    			     	<li class="<?php echo the_sub_field('indy_content'); ?>">
    			     		<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    			        </li>
    
    			        <?php } ?>
    
    			        <?php $h1 = false; ?>
    					<?php if ( $quick_link_column == "yes" ) { // Continue with the other links ?>	
    					<li class="<?php echo the_sub_field('indy_content'); ?>">
    							<a href="<?php the_sub_field('pro_download_link'); ;?>"><?php the_sub_field('pro_download_name'); ?></a>
    					</li>
    
    			        <?php } else {
    					// something else
    			        } ?>
    			     
    			<?php endwhile; ?>
    			<?php wp_reset_postdata(); ?>
    
    		</ul>
    		
    
    <?php endif; ?>
    
    </div><!-- end Quicklinks Sidebar -->
  • It says line 20:

    <?php} if ( $quick_link_column == "yes" ) { // Continue with the other links ?>

  • Hi Divebass,

    I haven’t been able to test it because there seems to be some syntax errors in the code. I always get confused when colons and curly brackets appear within the loop. My debugger says there is an unexpected bracket and when I delete it keeps going on from there…unexpected WHILE… etc. Do you identify what the error might be? Soooo close…

  • Thanks Divebass,

    Your solution appears to make good sense! I won’t be able to give it a whirl until later on today but I didn’t want to delay my response any longer as I am so grateful for your time in trying to work this through with me. Ill let you know soon (and mark resolved) if it solves my challenge. Thanks again.

  • Thanks for the reply but that answer does not help me. That makes the heading appear in the Sidebar whenever an entry exists whether it is located in the main content area or sidebar. So if the entry is meant for the main content, a heading is injected into the sidebar with no content beneath it which is undesirable.

    I had gotten that far, but I need it to display the heading in the sidebar ONLY if the “yes” check box (indicating the entry should be a Quicklink and therefore located in the sidebar) is chosen.

    Any other thoughts? Thanks again for your help with this, it really gotten me stuck.

Viewing 13 posts - 1 through 13 (of 13 total)