Recent Topics

1 Feb 26, 2014 06:12    

This post has been created from a comment made by @filthio in this page: http://b2evolution.net/man/advanced-customization/themes-templates-skins/modifying-evoskins/custom-fields

The custom field code needs to be inserted in _item_content_inc.php. I wanted to put mine after the main article so I put it just before the line that says "// URL link, if the post has one:". Some skins might not have this line.

The default code $Item->custom_fields() with no parameters shows the title of each field bold, a <br /> at the end of each field, and the body of the field as unstyled body text. If you are happy with this format then leave it as it is. If you want to format the custom fields you will need to put some extra code in.

This is my sample amended code which displays the custom fields with the default style values - but unlike the simple code with no parameters this allows you to edit those values.

Note that if you do not have a 'field format' parameter the fields will display as an unstyled string, so you will almost always need this if you are not going with the default style.

// start custom fields code
          if( $disp == 'single' )
          {    // Display custom fields
              $Item->custom_fields( array(
			'before'      => '',
			'after'       => '',
			'field_format'	=> '<strong>$title$</strong> $value$<br />',
			) );
          }
 		// end custom fields code

To style this block you will need to add your html tags in the three parameter strings.

Update
That code was wrongly formatted. Try this:


// start custom fields code
          if( $disp == 'single' )
          {    // Display custom fields
              $Item->custom_fields( array(
				'before'      => '',
				'after'       => '',
				'field_format'	=> '$title$ $value$
',
				) );
          }
 		// end custom fields code

2 Feb 26, 2014 17:03

The custom field code normally needs to be inserted in _item_content_inc.php which is in your skin folder. I wanted to put mine after the main article so I put it just before the line that says "// URL link, if the post has one:". Some skins might not have this line. If you want the code elsewhere in the page just move it.

The default code $Item->custom_fields() with no parameters shows the title of each field bold, a <br /> at the end of each field, and the body of the field as unstyled body text. So each field appears on a new line, with a bold title. If you are happy with this format then leave it as it is. If you want to format the custom fields you will need to put some extra code in.

This is my sample amended code which displays the custom fields with the default style values - but unlike the simple code with no parameters this allows you to edit those values.

Note that if you do not have a 'field format' parameter the fields will display as an unstyled string, so you will almost always need this if you are not going with the default style.

Code


              $Item->custom_fields( array(
      'before'      => '',
      'after'       => '',
      'field_format'  => '<strong>$title$</strong> $value$<br />',
      ) );  
   

To style this block you will need to add your html tags in the three parameter strings. Here is another example, this time with styles:

$Item->custom_fields( array(
				'before'      => '<div class="customfieldbox">',
				'after'       => '</div>',
				'field_format'	=> '<p class="customfieldboxitem"><strong>$title$</strong> $value$</p>',
				) );


Form is loading...