The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-08-29 22:30
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.
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-08-30 07:47
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.
-
pbottcher
- AppGini Super Hero
- Posts: 1638
- Joined: 2018-04-01 10:12
Post
by pbottcher » 2020-09-01 10:54
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;">';
?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-09-02 09:50
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
-
pbottcher
- AppGini Super Hero
- Posts: 1638
- Joined: 2018-04-01 10:12
Post
by pbottcher » 2020-09-02 11:19
Hi Bruce,
just add a check if the current user is the admin
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-09-03 09:14
Thanks Pascal, I will give that a go.
-
bruceholt
- Veteran Member
- Posts: 100
- Joined: 2016-07-30 20:16
- Location: Australia
Post
by bruceholt » 2020-09-12 22:27
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......"
-
pbottcher
- AppGini Super Hero
- Posts: 1638
- Joined: 2018-04-01 10:12
Post
by pbottcher » 2020-09-13 09:06
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';
}
?>
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.