Page 1 of 1
Show users selected logo in navbar
Posted: 2020-08-29 22:30
by bruceholt
I have had a request that we allow users to add a logo to their custom details page and display it in the navbar.
The image would only be a small thumbnail and is stored in the "details" table. I did try:
Code: Select all
<img src="thumbnail.php?i=<%%VALUE(farm_logo)%%>&t=farm_details&f=farm_logo&v=dv" class="img-thumbnail" id="farm_logo-image" style="max-width: 200px;">
but all it shows is the default camera icon. I am not sure how to select it from the users table.
Re: Show users selected logo in navbar
Posted: 2020-08-30 07:47
by bruceholt
I also tried:
Code: Select all
<?php echo sqlValue("SELECT farm_logo FROM " . get_sql_from('farm_details', false, true)); ?>
but it only displays the file name and not the image.
Re: Show users selected logo in navbar
Posted: 2020-09-01 10:54
by pbottcher
Hi,
try
Code: Select all
<?php
$image=sqlValue("SELECT farm_logo FROM " . get_sql_from('farm_details', false, true));
$path="PATHTOYOURIMAGE/";
echo '<img src="'.$path.$image.'" class="img-thumbnail" id="farm_logo-image" style="max-width: 200px;">';
?>
Re: Show users selected logo in navbar
Posted: 2020-09-02 09:50
by bruceholt
HI Pascal,
That works great except, is there a way to stop the image showing if the user is logged in as admin?
Thanks Bruce
Re: Show users selected logo in navbar
Posted: 2020-09-02 11:19
by pbottcher
Hi Bruce,
just add a check if the current user is the admin
Re: Show users selected logo in navbar
Posted: 2020-09-03 09:14
by bruceholt
Thanks Pascal, I will give that a go.
Re: Show users selected logo in navbar
Posted: 2020-09-12 22:27
by bruceholt
Hi,
If a user doesn't upload an image, it shows the normal "error" (no image found) image. I have a default image in the images folder that I trying to display if the user has not uploaded an image.
The code I have tried, (amongst a heap of others) is:
Code: Select all
<?php
if(file_exists($image=sqlValue("SELECT farm_logo FROM " . get_sql_from('farm_details', false, true))))
$path="images/";
echo '<img src="'.$path.$image.'" class="navbar-brand" id="farm_logo-image" style="max-width: 150px; max-height: 50px; background-color: transparent">';
else {
$image = 'default.png';
}
?>
Unfortunately it is throwing this error: "( ! ) Parse error: syntax error, unexpected 'else' (T_ELSE) in......"
Re: Show users selected logo in navbar
Posted: 2020-09-13 09:06
by pbottcher
try
Code: Select all
<?php
if(file_exists($image=sqlValue("SELECT farm_logo FROM " . get_sql_from('farm_details', false, true)))) {
$path="images/";
echo '<img src="'.$path.$image.'" class="navbar-brand" id="farm_logo-image" style="max-width: 150px; max-height: 50px; background-color: transparent">';
}
else {
$image = 'default.png';
}
?>