...

View Full Version : Just want to add a space at the beginning of return



sfraise
11-03-2010, 10:40 PM
The below code returns a radio list after an input box in a profile edit section.
All I want to do is add a space at the beginning of the radio list so to separate the input box and the radio list.
Where the magic happens here is on this line:


return $selhtml . ' ' . getFieldIcons( $_CB_framework->getUi(), $required, null, $fieldHandler->getFieldDescription( $field, $user, $output, $reason ), $fieldHandler->getFieldTitle( $field, $user, $output, $reason ) );


I've tried several variations of trying to use &nspb; both in the return string directly as well as creating a var for it. I've tried various ways of wrapping it in a div to simply add a margin, I've tried kicking my dog, I've tried banging my head against the wall, nothing seems to work. I either get a t var error, an unexpected something or other like . or & error depending on what I'm doing, or it tries to divide by zero using /'s.

Here's a larger view of the code:


function onFieldIcons( &$fieldHandler, &$field, &$user, $output, $reason, $tag, $type, $value, $additional, $allValues, $displayFieldIcons, $required ) {
global $_CB_framework, $ueConfig, $_CB_fieldIconDisplayed;

if ( is_object( $field->params ) ) {
$privacyLevel = $field->params->get( 'plug_cbprivacy_level' );
} else {
$privacyLevel = 0;
}

if ( $displayFieldIcons && ( $reason != 'search' ) ) {
if ( ( $privacyLevel == 1 ) && ( $field->profile != 0 ) ) {

$privacy =& moscomprofilerPrivacy::getInstance( $user, 'field', $field->fieldid );
$selected = ( $privacy ? $privacy->rule : '' );

$selectorName = $field->name . '___cbprivacy';

$connTypes = array();
if ( $this->params->get( 'conns_by_type', 0 ) ) {
if ( $ueConfig['connection_categories'] ) {
$connTypes = explode( "\n", $ueConfig['connection_categories'] );
foreach ( array_keys( $connTypes ) as $k) {
$connTypes[$k] = trim( $connTypes[$k] );
}
}
if ( $selected == 2 ) {
$type = $privacy->getParam( 'conn_cat' );
if ( $type ) {
$selected = $selected . '|*|' . $type;
}
}
}
$options = array();
$options[] = moscomprofilerHTML::makeOption( '', '' . CBTxt::T('     ') );
if ( ( $ueConfig['allow_profileviewbyGID'] == -2 ) && $this->params->get( 'prop_registered', 1 ) ) {
$options[] = moscomprofilerHTML::makeOption( '1', '' . CBTxt::T('     ' ) );
}
if ( $ueConfig['allowConnections'] ) {
$prop_connections = $this->params->get( 'prop_connections', 1 );
if ( $prop_connections ) {
$options[] = moscomprofilerHTML::makeOption( '2', '' . CBTxt::T( '     ' ) );
}
if ( count( $connTypes ) > 1 ) {
foreach ($connTypes as $type ) {
$options[] = moscomprofilerHTML::makeOption( '2|*|' . htmlspecialchars( $type ), ( $prop_connections ? '  ⌊ ' : '' ) . '' . sprintf( CBTxt::T( 'Only for %s' ), $type ) );
}
}
if ( $this->params->get( 'prop_fofs', 1 ) ) {
$options[] = moscomprofilerHTML::makeOption( '3', '' . CBTxt::T( 'Also for friends of friends' ) );
}
}
if ( $this->params->get( 'prop_invisible', 1 ) ) {
$options[] = moscomprofilerHTML::makeOption( '99', '' . CBTxt::T( ' ' ) );
}
$selHtml = moscomprofilerHTML::radioList( $options, $selectorName, '', 'value', 'text', $selected, 2, false );
if ( isset( $_CB_fieldIconDisplayed[$field->fieldid] ) ) {
return $selHtml;
} else {
$_CB_fieldIconDisplayed[$field->fieldid] = true;
return $selHtml . ' ' . getFieldIcons( $_CB_framework->getUi(), $required, null, $fieldHandler->getFieldDescription( $field, $user, $output, $reason ), $fieldHandler->getFieldTitle( $field, $user, $output, $reason ) );
}
} else {
if ( isset( $_CB_fieldIconDisplayed[$field->fieldid] ) ) {
return null;
} else {
$_CB_fieldIconDisplayed[$field->fieldid] = true;
return getFieldIcons( $_CB_framework->getUi(), $required, $field->profile, $fieldHandler->getFieldDescription( $field, $user, $output, $reason ), $fieldHandler->getFieldTitle( $field, $user, $output, $reason ) );
}

}

} else {
return null;
}
}


The basic layout here is this:
|inputbox||radio list|
But I want:
|inputbox| |radio list|

sfraise
11-03-2010, 11:18 PM
SOLVED

I created a var for it
$nbsp = " ";

Then added the var to the beginning of the string with a . at the end
return $nbsp. $selHtml blablabla

I new if I just kept kicking the dog it would come to me.

MattF
11-03-2010, 11:38 PM
No need to create a var. Just add it straight:



return ' '.$selhtml.' '

DrDOS
11-04-2010, 01:06 AM
And PHP takes text formatting literally so if you use an actual space and not & nbsp ; it may work just as well.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum