News:

Wondering if this will always be free?  See why free is better.

Main Menu

Clickable avatar.

Started by richardwbb, March 25, 2017, 04:49:32 PM

Previous topic - Next topic

richardwbb

I apologize for my [last] rant. I sincerily say that I didn't read back anything up to this point. [But will do.]

Is there a way to make just the user avatar clickable to profile. If that would be all avatars, that would make me happy to.

Greetings.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Arantor

The default theme does this, as evidenced by your picture above.

Antechinus

Depends which avatar he's talking about. The one in the default theme header isn't linked.

Also:

Quote from: richardwbb on March 25, 2017, 04:49:32 PMIs there a way to make just the user avatar clickable to profile.

Are you saying you want to remove all other links to profile, leaving just the avatar linked?

richardwbb

Quote from: Antechinus on March 25, 2017, 05:09:30 PM
Are you saying you want to remove all other links to profile, leaving just the avatar linked?

I'm not getting what you have wirtten. The default theme doesn't link indeed. Is that a 'standard of fora software'.

I have;
if ($context['user']['is_guest'] || empty($context['user']['avatar']['image']))
echo '<p class="avatar"><img src="' . $settings['images_url'] . '/nophoto.gif" alt="No avatar" height="100" width="100" /></p>';
if (!empty($context['user']['avatar']))
echo '', $context['user']['avatar']['image'], '';


And I've gotten myself; /index.php?action=profile;area=forumprofile, which should work I suppose. Now the 'context-user' I'm not getting. I collapsed on the manual which is my problem, not smf's. Could someone point me in the right direction.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Antechinus

That's not default theme markup you have there. It's custom code.

richardwbb

Thank you for clarifying. I happen to have a customized, customized, customized template. It are the looks that aren't easy to keep. That is a user preference of the 640 registered members we have there.


// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
if (!empty($context['user']['avatar']))
echo '
<p class="avatar">', $context['user']['avatar']['image'], '</p>';
echo '
<ul class="reset">
<li class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></li>
<li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';


The customized theme is 'Arobase', it went to a site admin that made it look, and I threw away tons of css, haha. It's running default besides index.template.php and profile.something.php, but that is another story. Oh, I'll be able to make this one work with the custom template, since I happen to have the idea/ need to import the [some, and step by step] php of index.template.php 2.0.12 or 2.1, which over time, will get easier, since it will become more readable to me by experience.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Antechinus

That markup is screwed. User refers to the person viewing the page. Member refers to the person who made the post that is being viewed.

// Don't show these things for guests.
if (!$message['member']['is_guest'])
{
// Show avatars, images, etc.?
if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
echo '
<p class="avatar">
<a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">
', $message['member']['avatar']['image'], '
</a>
</p>';
echo '
<ul class="reset">
<li class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></li>
<li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';

richardwbb

Quote from: Antechinus on March 29, 2017, 05:29:24 PM
That markup is screwed.

I've gotten it from a smf 2.0.11 default. AFAIK, that is original code. I've exchaged the quoted code I've posted with yours and it's showing no avatar but wait, there is a clock now. Maybe I didn't notice that untill now.

I'm not sure what is going on, could it be my bad. Should I install a clean smf 2.0.11 and post the code again maybe.

Here is a picture;

If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Antechinus

Oh right. We're talking about the theme header then, not posts. Will have some coffee.

richardwbb

Oh, lol. My timezone is dictating me tea, it's one hour before midnight and I should go sleep soon.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Antechinus

Ok, so if you want to use default markup, except with a clickable avatar, this should work:

// If the user is logged in, display stuff like their name, new messages, etc.
if ($context['user']['is_logged'])
{
if (!empty($context['user']['avatar']))
echo '
<p class="avatar"><a href="', $scripturl, '?action=profile;u=', $context['user']['id'], '">', $context['user']['avatar']['image'], '</a></p>';
echo '
<ul class="reset">
<li class="greeting">', $txt['hello_member_ndt'], ' <span>', $context['user']['name'], '</span></li>
<li><a href="', $scripturl, '?action=unread">', $txt['unread_since_visit'], '</a></li>
<li><a href="', $scripturl, '?action=unreadreplies">', $txt['show_unread_replies'], '</a></li>';

richardwbb

You are a good man Antechinus. I have unwittingly lied to you. I wrote it was default code while it wasn't. Somehow I was under the assumption copying and pasting from the index.template.php in my notepad-for-linuxers [geany], while I posted of a [out of my head;] 1.14 template that I made 2.0.3 and switched over to 2.0.11 [and accomplishing things to 'dress up' for 2.0.13' which isn't easy for me].

However, I assume you wrote that at once and seem to understand this important 'context' step. Now I'll show what it has become, and explain a bit;


My explanation; Without reading the new inserted code I'd say it has to do with the custom template [with indeed a mix up inside the php I admit], and it now isn't showing the login, but that I a div I am aware of. Now I propose I take over from here [this seems fair to me], this is looking doable for me [trial, error and learn], to make the non clickable, presumably original avatar, with next to it, your -clickable- avatar. So that is working flawlessly, it is some div thing and maybe you threw out some of my rubbish-code understandably. I'm hoping to learn this way the 'context-smf-way'. No real programmer here, however I made my own php - mysql address and phone number database with pdo, which looks easy to me now, I just don't get the 'smf context manual', which is my lack of understanding probably. Antechinus, many thanks allready and I appologize I mixed up the 'index.template.php and index.template.php' with geany. Oh, we should have exchanged the coffee and the tea, haha. My plan is to keep this look for the comming 2.1, that I find a challenge.When I get around to this I will post back here.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Antechinus

Righty o then. If you want to mess around with it some more it would probably be easier to just attach the actual template, along with an explanation of the problem. The CSS would probably be useful for diagnosis too.

richardwbb

At first it was a little hard for me to understand what was going on, but for my shown picture with the double avatar, that seemed a lack of knowledge, made by someone [and I'm not saying this couldn't have been me]. Taking the new knowledge [in this topic I mean], with me, to my plan to get eventually to 2.1 [and keep those modern features like the icons and some of the added features are really worth it], I made a simple edit, for which the 'magic' was;

echo '<a href="', $scripturl, '?action=profile;u=', $context['user']['id'], '">', $context['user']['avatar']['image'], '</a>';


That, instead of 'echo '', $context['user']['avatar']. So I learned that $context is what is says it is, that '[user]', is what it is, and now I learned this is an php array, where it is possble to just add '[image]', so that would be user 'to' avatar 'with' image.

Now I searched the context manual and then the forum and what I am looking for now is a list of 'contexts' like shown here in an old topic; https://www.simplemachines.org/community/index.php?topic=452303.msg3159358#msg3159358 Now I understand I might be able to generate my own 'array dump', and not knowing exactly how to do this, I also wonder, what are the meaning of '0' [disable I suppose], and '1' [enable I suppose] in relation to ' '. Antechninus, would you be so kind to shed some light on this, you already helped me understanding this index.template.php which is the only one that isn't 'default' any longer [besides three necessary css edits in Profile.template.php and some hand made edit's for modifications I didn't write down somewhere, I have come a long way with css, but the default css template held a quite well structure, so it had been possible to do so.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Antechinus

Yup, 0 and 1 are disable and enable.

richardwbb

Would somebody be so kind to explain in a few words '$context['user']['avatar']['image']' 'reverse engineered', please. I mean by this; I look at certain php files, trial and error some stuff and learn from there. While I was hinted to read a manual, I've come my way with 'SSI', however the 'context' manual just doesn't compute with me. The curve for me is steep and a bit slow. [I did notice that; contributing to this forum and specfically checking for support topics, my personal favourite; unicode, and helping out where the replies are low is the less steep curve for me][ Notice' it mostly isn't helpful to start helping where the regular team already had posted, YMMV.

To not make this another [long] post, please give me some directions, I'm not looking to be spoon fed, and, I am at a loss with learning to convert the custom index.template.php to 2.13 or is it 2.14 now, you can see that I 'fixed' things with css in this topic [if you are still interested]; https://www.simplemachines.org/community/index.php?topic=551342.msg3908797#msg3908797 [note that I specifically mean the last picture and see the boxing model on Internet Explorer, it hasn't a manual AFAIK and Firefox and Chrome *do* interpret some 'hardly used' css differently and that can be solved, you should take my word here because I lack proof of that. And for example, Arantor explained to me 'how to look to a couple of lines of '.htaccess', and before that I was able to make 'PrettyUrls', work with Apache 404 [and never got a reply of anyone]. What I want to say;

To anyone, please share some words, next to learning to write the whole 'index.template.php' which requires a general understanding of '$context' the least, I am after taking the whole thing to 2.1 [at least made my preparation already], and for what it matters, I've corrected a few modifications but while the impact was; large, and; sustainable in all browsers, the knowledge is scattered trough topics in this forum. [and some people just don't take a PM or something, boohoo]. Please help me a bit with '$context' is all I ask, how that is done written by you, isn't up to me anyway, and, usually; when I get the grasp, I am able to 'grab on my own'.


On a side note, I *could* post a long 'index.template.php', but Arantor wasn't happy with something I else I did before, so I'm stuck here, or; overlooking something. If I look stupid afterwards for something, so be it.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Arantor

$context is a huge bucket of things - an array in this case - that contains a lot of things about SMF's current running state.

$context['user'] is one element of that bucket, in this case a bucket of its own data relating to the current user. Set up by Load.php in the part where it loads the current user.

$context['user']['avatar'] is one element of that bucket, relating to data set up for the avatar. Also set up in the part where it loads the current user.

It sets up several variants of the avatar for different uses but 'image' is the version for the image itself. Check out the rest of the contents of $context['user']['avatar'] with print_r().

richardwbb

You're message has made it to my 'notepad++', where it will be sitting, when I start grasping php a bit [getting around to it/ do a long run of smf related things]. I now can see similarity in it's structure [php/ $context]. For that, I thank you Arantor.
If my post in this topic looks ambiguous to you, then I'm with Murphy's law and General Stupidity. In other words, trial and error.

Advertisement: