Editing Profile Field Options

Started by pepa, November 20, 2017, 06:21:48 AM

Previous topic - Next topic

pepa

One of the display options in the advanced profile fields i.e. in:

admin  -> core features
Enable "Advanced Profile Fields"
And save
Then go to admin -> Features and Options -> Profile fields



Is Standard (with title).  I want to change this so the Title isn't displayed.  Where is the code that needs editing and what do I change?

Arantor

What exactly are you trying to display? It's almost certainly doable without any code changes.

pepa

#2
Quote from: Arantor on November 20, 2017, 06:24:44 AM
What exactly are you trying to display? It's almost certainly doable without any code changes.

A New Field that has the Title "City" and Contents 'City Name' displays as i.e. in the user's profile at the left of a post:

City: City Name

I want just City Name displayed.

pepa

Quote from: pepa on November 20, 2017, 06:29:43 AM
Quote from: Arantor on November 20, 2017, 06:24:44 AM
What exactly are you trying to display? It's almost certainly doable without any code changes.

A New Field that has the Title "City" and Contents 'City Name' displays as i.e. in the user's profile at the left of a post:

City: City Name

I want just City Name displayed.

Another potential way around this would be to display the information by selecting the 'With Icons' Options in Choose Placement.  However the default text colour for this icon is black and so is the Icon colour.  If someone can point me to where in the css I can alter either of these colours (probably would need to be the Icon colour), I can try that as an option.

pepa

Quote from: pepa on November 20, 2017, 07:40:44 PM
Quote from: pepa on November 20, 2017, 06:29:43 AM
Quote from: Arantor on November 20, 2017, 06:24:44 AM
What exactly are you trying to display? It's almost certainly doable without any code changes.

A New Field that has the Title "City" and Contents 'City Name' displays as i.e. in the user's profile at the left of a post:

City: City Name

I want just City Name displayed.

Another potential way around this would be to display the information by selecting the 'With Icons' Options in Choose Placement.  However the default text colour for this icon is black and so is the Icon colour.  If someone can point me to where in the css I can alter either of these colours (probably would need to be the Icon colour), I can try that as an option.

Sorry, maybe not making a lot of sense to everyone about the Black Icon -> I'm using the Redsy Theme.

Sir Osis of Liver

Do you just the one custom field?  Do you want city to stay where it is (above date registered)?

Try this -

Profile.template.php



// Any custom fields for standard placement?
if (!empty($context['custom_fields']))
{
$shown = false;
foreach ($context['custom_fields'] as $field)
{
if ($field['placement'] != 0 || empty($field['output_html']))
continue;

if (empty($shown))
{
echo '
<dl>';
$shown = true;
}

if ($field['name'] == 'City')

echo '
<dt></dt>
<dd>', $field['output_html'], '</dd>';

else

echo '
<dt>', $field['name'], ':</dt>
<dd>', $field['output_html'], '</dd>';

}

if (!empty($shown))
echo '
</dl>';
}



Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on November 20, 2017, 11:15:54 PM
Do you just the one custom field?  Do you want city to stay where it is (above date registered)?

Try this -

Profile.template.php



// Any custom fields for standard placement?
if (!empty($context['custom_fields']))
{
$shown = false;
foreach ($context['custom_fields'] as $field)
{
if ($field['placement'] != 0 || empty($field['output_html']))
continue;

if (empty($shown))
{
echo '
<dl>';
$shown = true;
}

if ($field['name'] == 'City')

echo '
<dt></dt>
<dd>', $field['output_html'], '</dd>';

else

echo '
<dt>', $field['name'], ':</dt>
<dd>', $field['output_html'], '</dd>';

}

if (!empty($shown))
echo '
</dl>';
}



Thank you, I'm looking at adding a few custom fields.  I want to display the information in the Redsy theme, when a member makes a post, in the Icon/Information that's at the left of that post.  Hope that's a bit clearer.

Sir Osis of Liver

Display.template.php



// Any custom fields for standard placement?
if (!empty($message['member']['custom_fields']))
{
foreach ($message['member']['custom_fields'] as $custom)
if (empty($custom['placement']) || empty($custom['value']))
if ($custom['title'] == 'City')

echo '
<li class="custom">', $custom['value'], '</li>';
else

echo '
<li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
}


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on November 20, 2017, 11:48:01 PM
Display.template.php



// Any custom fields for standard placement?
if (!empty($message['member']['custom_fields']))
{
foreach ($message['member']['custom_fields'] as $custom)
if (empty($custom['placement']) || empty($custom['value']))
if ($custom['title'] == 'City')

echo '
<li class="custom">', $custom['value'], '</li>';
else

echo '
<li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
}



Thank you again, unfortunately that code doesn't seem to make any difference.  Maybe I'm not being very clear.

In the attached image what I want displayed is:
Brisbane
Indooroopilly
AAPi+APS

So I don't want the field names City, Suburb, Affiliation displayed at all.

Sir Osis of Liver

It didn't work because you need to substitute your label 'City/Town' for 'City' in the code I posted.  However, if you want to remove the label from all custom fields in poster info, you don't need the if/else, just this -



// Any custom fields for standard placement?
if (!empty($message['member']['custom_fields']))
{
foreach ($message['member']['custom_fields'] as $custom)
if (empty($custom['placement']) || empty($custom['value']))
echo '
<li class="custom">', $custom['value'], '</li>';
}


Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on November 21, 2017, 04:06:52 PM
It didn't work because you need to substitute your label 'City/Town' for 'City' in the code I posted.  However, if you want to remove the label from all custom fields in poster info, you don't need the if/else, just this -



// Any custom fields for standard placement?
if (!empty($message['member']['custom_fields']))
{
foreach ($message['member']['custom_fields'] as $custom)
if (empty($custom['placement']) || empty($custom['value']))
echo '
<li class="custom">', $custom['value'], '</li>';
}



Thank you so much, almost perfect!  One little glitch, there appears to be an additional return after the First field's contents - the one displayed as Brisbane in the attached pic.


Sir Osis of Liver

Not on my computer, but post your code (or attach the file), I'll look at it tomorrow.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on November 21, 2017, 10:49:12 PM
Not on my computer, but post your code (or attach the file), I'll look at it tomorrow.

OK, I presume you mean display.template ... it's attached.

pepa

An one more thing ... just discovered than when viewed on mobile phone that entire icon isn't displayed.  SO now wondering if the info can be displayed both in the icon at the left of the post and also in the signature (which is where you would see it on a mobile phone)?

Sir Osis of Liver

Don't use mobile, so can't help much with that, but should be possible to detect mobile and display the profile fields in one location or the other rather than both.

The line spacing problem is something in the css, it only happens in Redsy.  Will look for it tonight.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

Quote from: Sir Osis of Liver on November 22, 2017, 11:50:31 AM
Don't use mobile, so can't help much with that, but should be possible to detect mobile and display the profile fields in one location or the other rather than both.

The line spacing problem is something in the css, it only happens in Redsy.  Will look for it tonight.

Thanks again, I do really appreciate all your excellent help with this.

Perhaps someone else can help with the mobile issue?

Sir Osis of Liver

No idea why the line spacing problem is happening, but you can fix it with this -

index.css



.poster ul li
{
background: #FFF;
padding: 0;
text-align: center;
}



It tightens up the spacing but it's even, and I think it looks better.

There is an option in profile field settings to place them above signature, but that removes them from poster info block.  Might be better just to do it that way, will display the same for all users.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

pepa

#17
Quote from: Sir Osis of Liver on November 22, 2017, 10:11:11 PM
No idea why the line spacing problem is happening, but you can fix it with this -

index.css



.poster ul li
{
background: #FFF;
padding: 0;
text-align: center;
}



It tightens up the spacing but it's even, and I think it looks better.

There is an option in profile field settings to place them above signature, but that removes them from poster info block.  Might be better just to do it that way, will display the same for all users.

Yes that works very well and, as you say, is a neater display - thanks again!

Yes the info can be displayed above the signature but there is a specific reason why I wanted it in the poster info block.  However it occurred to me that if it is simultaneously displayed in poster info block and above signature then at least it would be above signature when viewed on a mobile and I could live with that.

Do you know where that option could be enabled in the code, that would nicely resolve this whole issue?

pepa

Thanks again.  I resolved the issue by using most of your earlier code so ...

// Are there any custom profile fields for above the signature?
if (!empty($message['member']['custom_fields']))
{
foreach ($message['member']['custom_fields'] as $custom)
if (empty($custom['placement']) || empty($custom['value']))
echo
$custom['value'], ',&nbsp';
}


Seems to work OK, info is now displayed in both poster block and signature. Really impressed with the help in this community, open source is such a great concept : )

pepa

Removed the ',' before the &nbsp in teh code above and added an additional &nbsp instead.

pepa

#20
Quote from: Sir Osis of Liver on November 21, 2017, 04:06:52 PM
It didn't work because you need to substitute your label 'City/Town' for 'City' in the code I posted.  However, if you want to remove the label from all custom fields in poster info, you don't need the if/else, just this -



// Any custom fields for standard placement?
if (!empty($message['member']['custom_fields']))
{
foreach ($message['member']['custom_fields'] as $custom)
if (empty($custom['placement']) || empty($custom['value']))
echo '
<li class="custom">', $custom['value'], '</li>';
}



Changed from Redsy to Default Theme with Responsive Curve and now I can only get the above code to display the first two custom fields.  Is it possible that one field which is a Select Box won't display, unlikely it all worked in Redsy?

Same thing is happening when I modify the code (slightly) to also display the custom fields above the signature.

Advertisement: