prosilver French edition

First Letter Avatar - prosilver French edition

Re: First Letter Avatar

by cabot » Tue Dec 26, 2023 5:35 pm

You need to adapt the code to that of the extension.
The loop name is not the same and neither are the template variables.

So something like this:

Code: Select all

				{% if message.S_SHOW_AVATAR %}
					<div class="chat-row-avatar cbb-circular-avatar">
						{% if message.S_AUTHOR_AVATAR %}
							{{ message.S_AUTHOR_AVATAR }}
						{% else %}
							{% set formattedTitleString = message.S_AUTHOR_FULL %}
							{% set usernameFirstLetter = formattedTitleString|split('<a')|last|split('>')[1]|first %}
							<span class="avatar avatar-letter">{{ usernameFirstLetter }}</span>
						{% endif %}
					</div>
				{% endif %}
And for the CSS code, this should be enough:

Code: Select all

.cbb-circular-avatar .avatar-letter {
	--avatar-font-size: 30px;
}
:)
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm

Re: First Letter Avatar

by cabot » Tue Dec 26, 2023 5:41 pm

And don't forget that you mustn't modify the extension's prosilver style files, but copy them into the extension's prosiver_en style template directory.
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm

Re: First Letter Avatar

by bennybernaer » Tue Dec 26, 2023 6:16 pm

Thank you again! It sometimes takes a long time for me to search and I don't always understand exactly what needs to be adjusted.
User avatar
bennybernaer
Registered User
Posts: 724
Joined: Tue Mar 22, 2011 9:53 pm

Re: First Letter Avatar

by cabot » Wed Dec 27, 2023 10:59 am

For the dmzx's extensions, we're going to proceed differently. We're going to add two template variables to the listener.php file, which won't alter the way the extension works but will allow it to be extended.
One variable is used to test whether the user has an avatar and the other returns the first character of the user's name. Quite simply.

Who Visited This Topic
  • whovisitedthistopic/event/listener.php
    Find:

    Code: Select all

    				$this->template->assign_block_vars('whovisitedthistopic',array(
    					'USERNAME'			=> $username,
    					'USERNAME_COLOUR'	=> $user_colour,
    					'VISITS'			=> $visits,
    					'URL'				=> $url,
    					'AVATAR'			=> empty($avatar) ? '<img src="' . $this->phpbb_admin_path . 'images/no_avatar.gif" width="60px;" height="60px;" alt="" />' : $avatar,
    					'DATE'				=> $date
    				));
    Find:

    Code: Select all

    					'DATE'				=> $date
    Replace with:

    Code: Select all

    					'DATE'				=> $date,
    					// Add custom template var
    					'HAS_AVATAR'		=> !empty($avatar),
    					'AVATAR_LETTER'		=> mb_substr($username, 0, 1),
    whovisitedthistopic/styles/prosiler_fr/template/event/viewtopic_body_footer_before.html
    (file copied from the prosilver/template/event/ directory of the extension)
    Find:

    Code: Select all

    {% if PERMISSION_SHOW_AVATAR %}<span class="whovisitedthistopic-avatar">{{ whovisitedthistopic.AVATAR }}</span>{% endif %}
    Replace with:

    Code: Select all

    {% if PERMISSION_SHOW_AVATAR %}<span class="whovisitedthistopic-avatar">{% if whovisitedthistopic.HAS_AVATAR %}{{ whovisitedthistopic.AVATAR }}{% else %}<span class="avatar avatar-letter">{{ whovisitedthistopic.AVATAR_LETTER }}</span>{% endif %}</span>{% endif %}
    whovisitedthistopic/styles/prosiler_fr/theme/whovisitedthistopic.css

    Code: Select all

    .whovisitedthistopic-avatar {
    	position: relative;
    	display: inline-block;
    	width: 20px;
    	height: 20px;
    	margin-bottom: 2px;
    	vertical-align: middle;
    }
    
    .whovisitedthistopic-avatar img,
    .whovisitedthistopic-avatar .avatar-letter {
    	position: absolute;
    	-moz-transition: all 1s ease;
    	-webkit-transition: all 1s ease;
    	left: 0px;
    	top: 0px;
    	max-height: 20px;
    	max-width: 20px;
    }
    
    .whovisitedthistopic-avatar img:hover,
    .whovisitedthistopic-avatar .avatar-letter:hover {
    	left: -40px;
    	top: -40px;
    	max-height: 100px;
    	max-width: 100px;
    	box-shadow: 0 0 20px #000;
    	z-index: 10;
    }
    
    .whovisitedthistopic-avatar .avatar-letter {
    	--avatar-font-size: 14px;
    }
    
    .whovisitedthistopic-avatar .avatar-letter:hover {
    	--avatar-font-size: 110px;
    }
    

Member Profile Views
  • memberprofileviews/event/listener.php
    Find:

    Code: Select all

    			$this->template->assign_block_vars('member_viewed',array(
    				'USERNAME'			=> $username,
    				'USERNAME_COLOUR'	=> $user_colour,
    				'TIME'				=> $user_time,
    				'URL'				=> $url,
    				'AVATAR'			=> empty($avatar) ? '<img src="' . $this->phpbb_admin_path . 'images/no_avatar.gif" width="60px;" height="60px;" alt="" />' : $avatar,
    				'COUNTER'			=> $totalviewsmember['counter_user'],
    			));
    Find:

    Code: Select all

    				'COUNTER'			=> $totalviewsmember['counter_user'],
    Replace with:

    Code: Select all

    				'COUNTER'			=> $totalviewsmember['counter_user'],
    				// Add custom template var
    				'HAS_AVATAR'		=> !empty($avatar),
    				'AVATAR_LETTER'		=> mb_substr($username, 0, 1),
    memberprofileviews/styles/prosiler_fr/template/event/memberlist_view_contact_after.html.html
    Find:

    Code: Select all

    <div class="member-viewed-avatar">{member_viewed.AVATAR}</div>
    Replace with:

    Code: Select all

    <div class="member-viewed-avatar">{% if member_viewed.HAS_AVATAR %}{{ member_viewed.AVATAR }}{% else %}<span class="avatar avatar-letter">{{ member_viewed.AVATAR_LETTER }}</span>{% endif %}</div>
    memberprofileviews/styles/prosiler_fr/theme/memberprofileviews.css

    Code: Select all

    .memberprofilecount {
    	min-height: 22px;
    	color: #536482;
    	font-size: 14px;
    	text-align: center;
    	margin-top: 4px;
    	padding-top: 6px;
    }
    
    .memberprofileviewed {
    	font-size: 12px;
    	text-align: center;
    }
    
    .member-viewed-avatar {
    	position: relative;
    	display: inline-block;
    	width: 20px;
    	height: 20px;
    	margin-bottom: 2px;
    	vertical-align: middle;
    }
    
    .member-viewed-avatar img,
    .member-viewed-avatar .avatar-letter {
    	position: absolute;
    	-moz-transition: all 1s ease;
    	-webkit-transition: all 1s ease;
    	left: 0px;
    	top: 0px;
    	max-height: 20px;
    	max-width: 20px;
    }
    
    .member-viewed-avatar img:hover,
    .member-viewed-avatar .avatar-letter:hover {
    	left: -40px;
    	top: -40px;
    	max-height: 100px;
    	max-width: 100px;
    	box-shadow: 0 0 20px #000;
    	z-index: 10;
    }
    
    .member-viewed-avatar .avatar-letter {
    	--avatar-font-size: 14px;
    }
    
    .member-viewed-avatar .avatar-letter:hover {
    	--avatar-font-size: 110px;
    }
    
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm

Re: First Letter Avatar

by bennybernaer » Wed Dec 27, 2023 2:41 pm

Made all changes and it works perfectly carbot.
And haha, I don't think it all sounds that simple.

In the "memberprofile views" I was already playing in the listener.php file a few days ago, but I assumed that I had to change something here: <img src="' . $this->phpbb_admin_path . 'images/no_avatar.gif" width="60px;" height="60px;" alt="" />'


Not right after all... Luckily I still have you. :) Thank you!
User avatar
bennybernaer
Registered User
Posts: 724
Joined: Tue Mar 22, 2011 9:53 pm

Re: First Letter Avatar

by cabot » Wed Dec 27, 2023 6:01 pm

bennybernaer wrote: In the "memberprofile views" I was already playing in the listener.php file a few days ago, but I assumed that I had to change something here: <img src="' . $this->phpbb_admin_path . 'images/no_avatar.gif" width="60px;" height="60px;" alt="" />'
It is possible to change this but it would have an impact on all styles, whereas simply adding template variables does not change the default behaviour of the extension and you are free to use them or not.
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm

Re: First Letter Avatar

by bennybernaer » Wed Dec 27, 2023 7:20 pm

Okay thanks! It is quite complicated to find the correct set of formattedTitleString

Code: Select all

		<div class="topic_preview_avatar">
			{%- if preview.TOPIC_PREVIEW_FIRST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
				{{ preview.TOPIC_PREVIEW_FIRST_AVATAR }}
			{%- else -%}
				{% set formattedTitleString = preview.topic_preview_first_avatar %}
							{% set usernameFirstLetter = formattedTitleString|split('<a')|last|split('>')[1]|first %}
							<span class="avatar avatar-letter">{{ usernameFirstLetter }}</span>
			{%- endif -%}
		</div>
{% set formattedTitleString = preview.topic_preview_first_avatar %}
User avatar
bennybernaer
Registered User
Posts: 724
Joined: Tue Mar 22, 2011 9:53 pm

Re: First Letter Avatar

by cabot » Thu Dec 28, 2023 1:16 pm

It's not possible to do this in HTML alone, you need to modify the PHP.
But the code for this extension is too complicated for me. :oops:
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm

Re: First Letter Avatar

by bennybernaer » Thu Dec 28, 2023 1:50 pm

cabot wrote:It's not possible to do this in HTML alone, you need to modify the PHP.
But the code for this extension is too complicated for me. :oops:
No problem Carbot! I think it's great that you're willing to put so much effort into this.
User avatar
bennybernaer
Registered User
Posts: 724
Joined: Tue Mar 22, 2011 9:53 pm

Re: First Letter Avatar

by bennybernaer » Thu Dec 28, 2023 5:14 pm

Then it probably won't be obvious for the national flags either?
User avatar
bennybernaer
Registered User
Posts: 724
Joined: Tue Mar 22, 2011 9:53 pm

Re: First Letter Avatar

by cabot » Thu Dec 28, 2023 6:06 pm

I'm not familiar with this extension, what is it?
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm

Re: First Letter Avatar

by bennybernaer » Thu Dec 28, 2023 6:11 pm

cabot wrote:I'm not familiar with this extension, what is it?
National Flags
User avatar
bennybernaer
Registered User
Posts: 724
Joined: Tue Mar 22, 2011 9:53 pm

Re: First Letter Avatar

by cabot » Fri Dec 29, 2023 11:28 am

As with dmzx extensions, it is possible to add a few lines without degrading the extension's native behaviour.

Open ext/rmcgirr83/nationalflags/controller/main_controller.php
Find:

Code: Select all

			$user_avatar = '';
Add after:

Code: Select all

			$has_avatar = true;
Find:

Code: Select all

					$user_avatar = '<img class="avatar" src="' . $avatar['user_avatar'] . '" width="' . $avatar['user_avatar_width'] . '" height="' . $avatar['user_avatar_height'] . '" alt="' . $this->language->lang('USER_AVATAR') . '" />';
Add after:

Code: Select all

					$has_avatar = false;
Find:

Code: Select all

				'U_SEARCH_USER'		=> ($this->auth->acl_get('u_search')) ? append_sid("{$this->root_path}search.$this->php_ext", "author_id=$user_id&amp;sr=posts") : '',
Add after:

Code: Select all

				'HAS_AVATAR'		=> $has_avatar,
				'AVATAR_LETTER'		=> mb_substr($userrow['username'], 0, 1),
Open ext/rmcgirr83/nationalflags/styles/prosilver_fr/template/event/overall_header_stylesheets_after.html
Add:

Code: Select all

{% if S_FLAGS %}
<style>
ul.topiclist dt.has-avatar-letter {display: flex; align-items: center; gap: 5px;}
.flag_inner .avatar-letter {--avatar-font-size: 20px; cursor: default;}
</style>
{% endif %}
Open ext/rmcgirr83/nationalflags/styles/prosilver_fr/template/flag_users.html
Find:

Code: Select all

						<dt class="flag_inner">
							{% if user_row.USER_AVATAR %}{{ user_row.USER_AVATAR }}{% endif %} {{ user_row.USERNAME_FULL }}
Replace with:

Code: Select all

						<dt class="flag_inner{% if not user_row.HAS_AVATAR %} has-avatar-letter{% endif %}">
							{% if user_row.USER_AVATAR %}{% if user_row.HAS_AVATAR %}{{ user_row.USER_AVATAR }}{% else %}<span class="avatar avatar-letter">{{ user_row.AVATAR_LETTER }}</span>{% endif %}{% endif %} {{ user_row.USERNAME_FULL }}
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm

Re: First Letter Avatar

by bennybernaer » Fri Dec 29, 2023 5:16 pm

Thank you! Functions perfectly!
User avatar
bennybernaer
Registered User
Posts: 724
Joined: Tue Mar 22, 2011 9:53 pm

Re: First Letter Avatar

by cabot » Tue Jan 02, 2024 2:00 pm

I've tried to find a solution for the Topic Preview extension, can you give it a try?

ext/vse/topicpreview/core/data.php
Find:

Code: Select all

		$avatar_ary = array(
			'user_avatar'        => 'avatar',
			'user_avatar_type'   => 'avatar_type',
			'user_avatar_width'  => 'avatar_width',
			'user_avatar_height' => 'avatar_height',
		);
Replace with:

Code: Select all

		$avatar_ary = array(
			'user_avatar'        => 'avatar',
			'user_avatar_type'   => 'avatar_type',
			'user_avatar_width'  => 'avatar_width',
			'user_avatar_height' => 'avatar_height',
			'username'			 => 'username',
		);
ext/vse/topicpreview/core/display.php
Find:

Code: Select all

		$block = array_merge($block, array(
			'TOPIC_PREVIEW_FIRST_POST'		=> $this->get_text_helper($row, 'first_post_text'),
			'TOPIC_PREVIEW_LAST_POST'		=> $this->get_text_helper($row, 'last_post_text'),
			'TOPIC_PREVIEW_FIRST_AVATAR'	=> $this->get_user_avatar_helper($row, 'fp'),
			'TOPIC_PREVIEW_LAST_AVATAR'		=> $this->get_user_avatar_helper($row, 'lp'),
		));
Replace with:

Code: Select all

		$block = array_merge($block, array(
			'TOPIC_PREVIEW_FIRST_POST'		=> $this->get_text_helper($row, 'first_post_text'),
			'TOPIC_PREVIEW_LAST_POST'		=> $this->get_text_helper($row, 'last_post_text'),
			'TOPIC_PREVIEW_FIRST_AVATAR'	=> $this->get_user_avatar_helper($row, 'fp'),
			'TOPIC_PREVIEW_LAST_AVATAR'		=> $this->get_user_avatar_helper($row, 'lp'),
			'TOPIC_PREVIEW_FIRST_USERCHAR'	=> $this->get_username_first_char($row, 'fp'),
			'TOPIC_PREVIEW_LAST_USERCHAR'	=> $this->get_username_first_char($row, 'lp'),
		));
Find:

Code: Select all

		return $avatar ?: self::NO_AVATAR;
	}
Add after:

Code: Select all

	protected function get_username_first_char($row, $poster)
	{
		if (!$this->avatars_enabled())
		{
			return '';
		}

		$username_first_char = '';
		if (empty($row[$poster . '_avatar']))
		{
			$username_first_char =  mb_substr($row[$poster . '_username'], 0, 1);
		}

		return $username_first_char;
	}
In ext/vse/topicpreview/styles/
Create a new directory and file:
  • prosilver_fr/
    • |__ template/
      • |__ topicpreview.html

        Code: Select all

        <div class="topic_preview_content" style="display:none;">
        	{% if preview.TOPIC_PREVIEW_LAST_POST %}
        		<strong>{{ lang('FIRST_POST') }}</strong>
        		<hr />
        	{% endif %}
        	{% if preview.TOPIC_PREVIEW_FIRST_AVATAR %}
        	<div class="topic_preview_avatar">
        			{%- if preview.TOPIC_PREVIEW_FIRST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
        				{{ preview.TOPIC_PREVIEW_FIRST_AVATAR }}
        			{%- else -%}
        				<span class="avatar avatar-letter" style="--avatar-font-size: 44px;">{{ preview.TOPIC_PREVIEW_FIRST_USERCHAR }}</span>
        			{%- endif -%}
        		</div>
        	{% endif %}
        	<div class="topic_preview_first">{{ preview.TOPIC_PREVIEW_FIRST_POST }}</div>
        	{% if preview.TOPIC_PREVIEW_LAST_POST %}
        		<div class="topic_preview_break"></div>
        		<strong>{{ lang('LAST_POST') }}</strong>
        		<hr />
        		{% if preview.TOPIC_PREVIEW_LAST_AVATAR %}
        		<div class="topic_preview_avatar">
        				{%- if preview.TOPIC_PREVIEW_LAST_AVATAR != constant('\\vse\\topicpreview\\core\\display::NO_AVATAR') -%}
        					{{ preview.TOPIC_PREVIEW_LAST_AVATAR }}
        				{%- else -%}
        					<span class="avatar avatar-letter" style="--avatar-font-size: 44px;">{{ preview.TOPIC_PREVIEW_LAST_USERCHAR }}</span>
        				{%- endif -%}
        			</div>
        		{% endif %}
        		<div class="topic_preview_last">{{ preview.TOPIC_PREVIEW_LAST_POST }}</div>
        	{% endif %}
        </div>
User avatar
cabot
Jr. Style Validator
Posts: 990
Joined: Sat Jan 07, 2012 4:16 pm