Recent Topics

1 Apr 11, 2010 09:18    

My b2evolution Version: Not Entered

What are the custom fields for and how do I use it?

2 Apr 11, 2010 14:25

hi hip rock

its for the modification of your posts.

try to test it

Custom fields can be defined for each blog under "Blog Settings > Features".

3 Jul 22, 2010 03:32

I enter titles for custom fields, save, and go to 'new post' - where there is no evidence of new fields. I am assuming that new fields will appear with text fields in the 'new post' area. Should I be looking for something else? What?

5 Jul 22, 2010 05:17

Thanks for pointing me to that. Didn't come up in a search. But I don't know I am any the wiser!

I take it I insert

¥åßßå wrote:

<?php
for( $i = 1; $i < 5; $i++ )
{
  $var = 'double'.$i;
  if( !empty( $Item->$var ) )
  {
    $field_name = $Blog->get_setting('custom_double'.$i);
    //display custom field name
    echo ''.$field_name.':';
    //display custom field value
    echo $Item->$var;
  } 
}
?>

;)

¥

in _item_content_inc.php. But where? And where do I enter the custom value? Or do I misunderstand the whole thing? I am assuming that this will function in such a way that in a post I can have in effect a template which has the main post content area, and sub-areas which are named as per varchar1, varchar1, for example, and the value of varchar1, varchar2 will be displayed near the respective name.

6 Jul 22, 2010 05:38

Let's say you have a blog about T-shirts
- create new fields "Size"(double1), "Price"(double2), "Color"(varchar1)
- create a post "Cool T-shirt" and fill the values
- in your skin add the following to _item_block.inc.php wherever you like

if( $Item->varchar1 && $Item->double1 && $Item->double2 )
{
	echo sprintf( 'This T-shirt is %s, its size is %s. Buy it for $%s!', $Item->varchar1, $Item->double1, $Item->double2 );
}

7 Jul 22, 2010 05:51

I am using dark contrast, which does not have _item_block.inc.php. Will it work in single.main.php or posts.main.php? And this after I have included above code anywhere in item_content_inc.php? I am confused.

Where do I fill in the values? Presumably in admin, edit post.

8 Jul 22, 2010 10:15

Put this code in any *.main.php file except for index.main.php, you can put it in _item_content_inc.php too.

Where do I fill in the values? Presumably in admin, edit post.

That's right, add fields on Blog settings > Features tab and fill in values on post edit tab

<?php
// List all tags attached to this post:
$Item->tags( array(
		'before' =>         '<div class="posttags">'.T_('Tags').': ',
		'after' =>          '</div>',
		'separator' =>      ', ',
	) );

if( $Item->varchar1 && $Item->double1 && $Item->double2 )
{
    echo sprintf( 'This T-shirt is %s, its size is %s. Buy it for $%s!', $Item->varchar1, $Item->double1, $Item->double2 );
} 
?>

9 Jul 22, 2010 11:52

Thanks Sam - I'll give it a go. I think I get the logic of it. Once I insert the code, the fields will appear in admin in some fashion... although I don't see what brings the fields into admin.

I'll do it on a test site so I don't upset the database if I screw up.

10 Jul 22, 2010 20:19

You can always change field names. The content will not be affected.


Form is loading...