CB / Seblod integration

11 years 7 months ago #209795 by lucvillalba
CB / Seblod integration was created by lucvillalba
Hello,

I'm using CB 1.8.1 for users management and Seblod 2.3.9 for content construction.
I display a list of recently created articles. All my seblod fields are displayed but I can't display the avatar and formatname from community builder.

The avatar should be on the left of each content:


I tried subsitutions...
I used this code to call CB API
global $_CB_framework, $mainframe;
 
if ( defined( 'JPATH_ADMINISTRATOR' ) ) {
    // Joomla! 1.5 ou supérieur
    if ( ! file_exists( JPATH_ADMINISTRATOR .
        '/components/com_comprofiler/plugin.foundation.php' ) ) {
        echo 'CB non installé!';
        return;
    }
    include_once( JPATH_ADMINISTRATOR .
        '/components/com_comprofiler/plugin.foundation.php' );
} else {
    // Joomla! 1.0 ou Mambo CMS
    if ( ! file_exists( $mainframe->getCfg( 'absolute_path' ) .
        '/administrator/components/com_comprofiler/plugin.foundation.php' ) ) {
        echo 'CB non installé!';
        return;
    }
    include_once( $mainframe->getCfg( 'absolute_path' ) .
        '/administrator/components/com_comprofiler/plugin.foundation.php' );
}
cbimport( 'cb.database' ); // import manipulations de la base de données
cbimport( 'language.front' ); // Gestion des langues CB
cbimport( 'cb.imgtoolbox' ); // Fonction de ImageToolbox de CB
cbimport( 'cb.html' ); // Classe et fonctions de rendu HTML
cbimport( 'cb.plugins' ); // accès aux plugins CB

I tried substitutions in a free text field to call CB field, and i tried substitution too on typo HTML but doesn't work...


Anyone have a solution to display the avatar and formatname of community builder?

Thank you in advance and sorry for my English, i'm French...
Luc
Attachments:

Please Log in to join the conversation.

11 years 7 months ago #209830 by krileon
Replied by krileon on topic Re: CB / Seblod integration
See below tutorial for calling CB fields with CB API.

www.allmysocials.com/directory/tutorials/item/235-obtaining-field-values-through-api


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

11 years 7 months ago - 11 years 7 months ago #209916 by lucvillalba
Replied by lucvillalba on topic Re: CB / Seblod integration
I followed the tutorial but I lose my site template when php code is called in the seb_one template. Here is the error:
Fatal error: Class 'CBuser' not found in D:\Sites\www\xxxxxxxxxx\templates\seb_one\index.php on line 294

Here is the code I used:
$cbUser =& CBuser::getInstance( $user->id );
 
if ( ! $cbUser ) {
$cbUser =& CBuser::getInstance( null );
} 
function getField( $fieldName, $defaultValue = null, $output = 'html', $formatting = 'none', $reason = 'profile', $list_compare_types = 0 ){
$avatar	= $cbUser->getField( 'avatar', null, 'html', 'none', 'list' );}
'<div>'.$avatar.'</div>'

Please Log in to join the conversation.

11 years 7 months ago #209927 by krileon
Replied by krileon on topic Re: CB / Seblod integration
Re-read the tutorial. You did not include CB API.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

11 years 7 months ago #209953 by lucvillalba
Replied by lucvillalba on topic Re: CB / Seblod integration
Ok I was wrong.

I redid the code. It seems to work except it does not retrieve the user id. html rendering looks ok. Here is a screenshot more explicit.



Here is my index.php from Seblod template with the CB API call and the CB fields call:
<?php
/**
* @version 			SEBLOD 2.x Core
* @package			SEBLOD (App Builder & CCK) // SEBLOD nano (Form Builder)
* @url				http://www.seblod.com
* @editor			Octopoos - www.octopoos.com
* @copyright		Copyright (C) 2012 SEBLOD. All Rights Reserved.
* @license 			GNU General Public License version 2 or later; see _LICENSE.php
**/

// No Direct Access
defined( '_JEXEC' ) or die;

// -- Initialize
require_once dirname(__FILE__).DS.'config.php';
$cck	=	CCK_Rendering::getInstance( $this->template );
if ( $cck->initialize() === false ) { return; }

$class_table	=	trim( $cck->getStyleParam( 'class_table', 'category zebra' ) );
$class_table	=	$class_table ? ' class="'.$class_table.'"' : '';
$class_row0		=	trim( $cck->getStyleParam( 'class_table_tr_even', 'cat-list-row%i' ) );
$class_row0		=	$class_row0 ? ' class="'.str_replace( '%i', '0', $class_row0 ).'"' : '';
$class_row1		=	trim( $cck->getStyleParam( 'class_table_tr_odd', 'cat-list-row%i' ) );
$class_row1		=	$class_row1 ? ' class="'.str_replace( '%i', '1', $class_row1 ).'"' : '';

$doc	=	JFactory::getDocument();
$doc->addStyleSheet( JURI::root( true ).'/templates/'.$cck->template. '/css/'.'base.css' );
// -- CB API
global $_CB_framework, $mainframe;
 
if ( defined( 'JPATH_ADMINISTRATOR' ) ) {
	if ( ! file_exists( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' ) ) {
		echo 'CB not installed!';
		return;
	}
 
	include_once( JPATH_ADMINISTRATOR . '/components/com_comprofiler/plugin.foundation.php' );
} else {
	if ( ! file_exists( $mainframe->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/plugin.foundation.php' ) ) {
		echo 'CB not installed!';
		return;
	}
 
	include_once( $mainframe->getCfg( 'absolute_path' ) . '/administrator/components/com_comprofiler/plugin.foundation.php' );
} 
cbimport( 'cb.database' );
cbimport( 'language.front' );
cbimport( 'cb.imgtoolbox' );
cbimport( 'cb.html' );
cbimport( 'cb.plugins' );
// -- Render
?>
<div id="<?php echo $cck->id; ?>" class="cck-f100 cck-pad-<?php echo $cck->getStyleParam( 'position_margin', 8 ); ?>">
    <div>
    <?php
	$css		=	array();
	$items		=	$cck->getItems();
	$positions	=	$cck->getPositions();
	if ( count( $items ) ) { ?>
		<table<?php echo $class_table; ?>>
            <thead>
                <tr>
				<?php
				foreach ( $positions as $name=>$position ) {
					$class		=	$position->css;
					$css[$name]	=	$class ? ' class="'.$class.'"' : '';
					$legend		=	( $position->legend ) ? $position->legend : ( ( $position->legend2 ) ? $position->legend2 : $name );
					$width		=	$cck->w( $name );
					$width		=	( $width ) ? ' width="'.$width.'"' : '';
					echo '<th'.$width.'>'.$legend.'</th>';
				}
                ?>
                </tr>
            </thead>
            <tbody>
            <?php
			$i	=	0;
            foreach ( $items as $item ) {
				?>
                <tr <?php echo ${'class_row'.($i % 2)}; ?>>
				<td><div class="avatar_formatname">
				<?php
				$cbUser =& CBuser::getInstance( $user->id );
				 
				if ( ! $cbUser ) {
				$cbUser =& CBuser::getInstance( null );
				} 
				function getField( $fieldName, $defaultValue = null, $output = 'html', $formatting = 'none', $reason = 'profile', $list_compare_types = 0 ){}
				$avatar	= $cbUser->getField( 'avatar', null, 'html', 'none', 'list');
				$formatname	= $cbUser->getField( 'formatname', null, 'html', 'none', 'list');
				echo '<div class="avatar_table">'.$avatar.'</div><div class="clr"></div><div class="formatname_table">'.$formatname.'</div>';
				/**
				* Formatter:
				* Returns a field in specified format
				*
				* @param  string    $fieldName               Name of field to render
				* @param  mixed     $defaultValue            Value if field is not in reach of viewer user or innexistant
				* @param  string    $output                  'html', 'xml', 'json', 'php', 'csvheader', 'csv', 'rss', 'fieldslist', 'htmledit'
				* @param  string    $formatting              'tr', 'td', 'div', 'span', 'none',   'table'??
				* @param  string    $reason                  'profile' for user profile view, 'edit' for user profile edit, 'register' for registration, 'search' for searches, 'list' for lists
				* @param  int       $list_compare_types      IF reason == 'search' : 0 : simple 'is' search, 1 : advanced search with modes, 2 : simple 'any' search
				* @return mixed                
				*/
				?>
				</div></td>
				<?php
                foreach ( $positions as $name=>$position ) {
                    $fieldnames	=	$cck->getFields( $name, '', false );
                    echo '<td'.$css[$name].'>';
                    foreach ( $fieldnames as $fieldname ) {
						$html	=	$item->renderField( $fieldname );
						if ( $html != '' ) {
	                        echo '<div style="clear:left;">'. $html .'</div>';	//todo: markup
						}
                    }
                    echo '</td>';
                }
                ?>
                </tr>
            <?php $i++; } ?>
			
			</tbody>
		</table>
	<?php } ?>
    </div>
</div>
<?php
// -- Finalize
$cck->finalize();
?>

Does anyone see the problem?
Attachments:

Please Log in to join the conversation.

11 years 7 months ago #209975 by krileon
Replied by krileon on topic Re: CB / Seblod integration
$user isn't defined. Please understand it's just a tutorial. It's not a working example. It's there to explain how the API functions. You need to define $user or replace $user->id with the actual id of the user viewing the page.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.275 seconds

Facebook Twitter LinkedIn