Replace icon user by photo and username

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
smpsrllc
User
Posts: 72

Replace icon user by photo and username

Post by smpsrllc »

The v2018 generates the icon like this:

<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span>
</a>

As a change to generate it as it does adminLTE:

<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
<img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
<span class="hidden-xs">Alexander Pierce</span>
</a>

I tray only for the photo this form:

client scripts -> Global -> Pages with header/footer -> Startup Script
remove icon user is working
$(".glyphicon-user").remove();

$(".dropdown-toggle").before('<img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">');

No working good.

Thank you for your help.


Webmaster
User
Posts: 9425

Post by Webmaster »

Use Page_Foot server event (read Server Events and Client Scripts in the help file) to add your own auto render template:

<script type="text/html" class="ewJsTemplate" data-name="login" data-data="login" data-method="appendTo" data-target=".navbar-custom-menu .nav">

...your template...

</script>

See the original template in footer.php as example.

You can use Startup Script also but you should use a more specific class name since "dropdown-toggle" is a general Bootstrap class for dropdown and there may be more than one.


hemin
User
Posts: 165

Post by hemin »

lets say we used this :

{{if isLoggedIn}}
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img src=" userprofile " class="user-image" alt=" " >
</a>
.............

how can i get another value like {{:currentUserName}} for instance {{:currentUserProfilePic}} where should i declare this variable?


Webmaster
User
Posts: 9425

Post by Webmaster »

You can set current user info to $LoginStatus, e.g. in Page_Loading server event (requires v2018.0.2)

LoginStatus("currentUserProfilePic", Profile("pic")); // Assume "pic" is a varchar field (not BLOB field) in the user table


smpsrllc
User
Posts: 72

Post by smpsrllc »

Hello

The scritp right is

<script type="text/html" class="ewJsTemplate" data-name="dropdown-toggle" data-method="replaceAll" data-target=".glyphicon-user" data-seq="5">
<img src="dist/img/user2-160x160.jpg" class="user-image" alt="User Image">
<span class="hidden-xs">Alexander Pierce</span>
</script>

Thanks


Post Reply