Get values from fields anywhere (SEBLOD 1.x )
Let's say that you are currently developing a module, or editing a existing one, or maybe writing some code from your cck custom template. And you need to get the value(s) of one or some field(s) from a specific article. (without any ::fieldname:: ).
Here are 2 functions that will do the job for you............. and you can call them anywhere!
CCK_GET_Value( $id, $fields, $mode = false )
Using this function, you just need to know the article id, and from which fields you want to get value(s).
Examples:
// $id is the id of my article.
$value = CCK_GET_Value( $id, 'my_text1' );
echo $value;or// $id is the id of my article.
$fields = array( 'my_text1', 'my_text2' );
$value = CCK_GET_Value( $id, $fields );
echo $value['my_text1'];
echo $value['my_text2'];
$id - id of article where you want to get value(s) (int)
$fields - fields you are interested in (string or array)
CCK_GET_ValueFromText( $text, $fields, $mode = false )
The second one assumes that you already got the text (introtext/fulltext) of your article.
Examples:
// $content is the content of my article.
$value = CCK_GET_ValueFromText( $content, 'my_text1' );
echo $value;
$text - text of article where you want to get value(s) (string)
$fields - fields you are interested in (string or array)
CCK_GET_Value( $id, $fields, $mode = false )
Using this function, you just need to know the article id, and from which fields you want to get value(s).
Examples:
// $id is the id of my article.
$value = CCK_GET_Value( $id, 'my_text1' );
echo $value;or// $id is the id of my article.
$fields = array( 'my_text1', 'my_text2' );
$value = CCK_GET_Value( $id, $fields );
echo $value['my_text1'];
echo $value['my_text2'];
$id - id of article where you want to get value(s) (int)
$fields - fields you are interested in (string or array)
CCK_GET_ValueFromText( $text, $fields, $mode = false )
The second one assumes that you already got the text (introtext/fulltext) of your article.
Examples:
// $content is the content of my article.
$value = CCK_GET_ValueFromText( $content, 'my_text1' );
echo $value;
$text - text of article where you want to get value(s) (string)
$fields - fields you are interested in (string or array)
SEBLOD - Bes
November 03, 2011
846
March 31, 2012
