- Posts: 9
COMMUNITY FORUM
SOLVED: Tutorial for extra fields?
- Maciej Charabin
- 
				
- Offline
- New Member
		Less
		More
		
			
	
		
			
	
						11 years 1 month ago				#103225
		by Maciej Charabin
	
	
		
			
	
			
			 		
													
	
				Replied by Maciej Charabin on topic Re: SOLVED: Tutorial for extra fields?			
			
				Hi Kirkor,
Maybe I'm wrong but there is the second foreach:			
					Maybe I'm wrong but there is the second foreach:
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->name=='Podtytul') continue; ?>
<?php endforeach; ?>Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- 
				
- Offline
- Platinum Member
		Less
		More
		
			
	
		- Posts: 15920
			
	
						11 years 1 month ago				#103226
		by Krikor Boghossian
	
	
		
			
	
			
			 		
													
	
				Replied by Krikor Boghossian on topic Re: SOLVED: Tutorial for extra fields?			
			
				You have:
You need:			
					<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>You need:
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>Please Log in or Create an account to join the conversation.
- Maciej Charabin
- 
				
- Offline
- New Member
		Less
		More
		
			
	
		- Posts: 9
			
	
						11 years 1 month ago				#103227
		by Maciej Charabin
	
	
		
			
	
			
			 		
													
	
				Replied by Maciej Charabin on topic Re: SOLVED: Tutorial for extra fields?			
			
				Now I have:
Extrafield 'Podtytul' is still in extrafeilds position... Where is the mistake???
					<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
                <ul>
                        
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->name=='Podtytul') continue; ?>
                        
                        <?php if($extraField->value != ''): ?>
                        <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
                                <?php if($extraField->type == 'header'): ?>
                                <h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
                                <?php else: ?>
                                
                                <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                                <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
                                <?php endif; ?>
                        </li>
                        <?php endif; ?>
                        <?php endforeach; ?>
                        </ul>Extrafield 'Podtytul' is still in extrafeilds position... Where is the mistake???
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- 
				
- Offline
- Platinum Member
		Less
		More
		
			
	
		- Posts: 15920
			
	
						11 years 1 month ago				#103228
		by Krikor Boghossian
	
	
		
			
	
			
			 		
													
	
				Replied by Krikor Boghossian on topic Re: SOLVED: Tutorial for extra fields?			
			
				You can try this			
					<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
<ul>
	<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
	<?php if($extraField->value != '' &&  $extraField->name != 'Podtytul'): ?>
	<li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
		<?php if($extraField->type == 'header'): ?>
		<h4 class="itemExtraFieldsHeader"><?php echo $extraField->name; ?></h4>
		<?php else: ?>
		<span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
		<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
		<?php endif; ?>
	</li>
	<?php endif; ?>
	<?php endforeach; ?>
</ul>Please Log in or Create an account to join the conversation.
- Maciej Charabin
- 
				
- Offline
- New Member
		Less
		More
		
			
	
		- Posts: 9
			
	
						11 years 1 month ago				#103229
		by Maciej Charabin
	
	
		
			
	
			
			 		
													
	
				Replied by Maciej Charabin on topic Re: SOLVED: Tutorial for extra fields?			
			
				Hi Kirkor,
I've found solution from there: [url=http://http://getk2.org/community/English-K2-Community/190438-Limiting-Extra-FieldsDisplay#191190]solution[/url], and I've copied this code to my item.php and now It's OK :)
Thank You for Your commitment and support :)
					I've found solution from there: [url=http://http://getk2.org/community/English-K2-Community/190438-Limiting-Extra-FieldsDisplay#191190]solution[/url], and I've copied this code to my item.php and now It's OK :)
<h3><?php echo JText::_('K2_ADDITIONAL_INFO'); ?></h3>
	  	<ul>
	<?php if($extraField->name=='Subtitle') continue; ?>		
<?php $fieldsToShow = array(1,2,3,4,5,6,7); //this is an array of fields keys/ids to show ?>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
      <?php if(in_array($key, $fieldsToShow)): ?>
             <li class="type<?php echo ucfirst($extraField->alias); ?> group<?php echo $extraField->group; ?>">
                     <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                       <span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
                 </li>
      <?php endif; ?>
<?php endforeach; ?>			</ul>Thank You for Your commitment and support :)
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- 
				
- Offline
- Platinum Member
		Less
		More
		
			
	
		- Posts: 15920
			
	
						11 years 1 month ago				#103230
		by Krikor Boghossian
	
	
		
			
	
			
			 		
													
	
				Replied by Krikor Boghossian on topic Re: SOLVED: Tutorial for extra fields?			
			
				You 're welcome :)			
					Please Log in or Create an account to join the conversation.