problem when I display the image categories on the main page.

Please report bugs here!

Moderator: Thorsten

Post Reply
blondin62
Posts: 34
Joined: Sun Mar 11, 2018 11:06 am

problem when I display the image categories on the main page.

Post by blondin62 » Sun May 24, 2020 10:58 am

hello Thorsen

I have a problem when I display the image categories on the main page.
for the first four categories the screen is perfect but if I add a fifth categerie the image appears very large, same with the sixth, the seventh etc until height . I made screeshots to understand better
You do not have the required permissions to view the files attached to this post.

Thorsten
Posts: 15025
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: problem when I display the image categories on the main page.

Post by Thorsten » Sun May 24, 2020 11:13 am

Hi,

yes, this is how Bootstrap responsiveness works... and you even tried only the desktop mode.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

blondin62
Posts: 34
Joined: Sun Mar 11, 2018 11:06 am

Re: problem when I display the image categories on the main page.

Post by blondin62 » Sun May 24, 2020 11:15 am

sorry but what do you call "desktop mode"

Thorsten
Posts: 15025
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: problem when I display the image categories on the main page.

Post by Thorsten » Sun May 24, 2020 11:20 am

Hi,

sorry, desktop means a screen size resolution over 1024px width

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist

blondin62
Posts: 34
Joined: Sun Mar 11, 2018 11:06 am

Re: problem when I display the image categories on the main page.

Post by blondin62 » Sun May 24, 2020 1:17 pm

I found a solution by modifying the file "categories helper.php".
on the same line I add empty images to always have 4
the lines added are commented with //FR
(this change may not be optimized)

public function renderStartPageCategories(array $categories): string
{
if (count($categories) === 0) {
return '';
}

$decks = '';
$key = 1;
$val = 1; // FR compteur d'image
foreach ($categories as $category) {
$decks .=
'<div class="card mb-4">' .
'<a href="' . $category['url'] . '">' .
'<img class="card-img-top img-fluid" width="400" src="' . $category['image'] . '" alt="' .
$category['name'] . '" />' .
'</a>' .
'<div class="card-body">' .
'<h4 class="card-title text-center">' .
'<a href="' . $category['url'] . '">' . $category['name'] . '</a>' .
'</h4>' .
'<p class="card-text">' . $category['description'] . '</p>' .
'</div>' .
'</div>';
if ($key % 2 === 0) {
$decks .= '<div class="w-100 d-none d-sm-block d-md-none"></div>';
}
if ($key % 3 === 0) {
$decks .= '<div class="w-100 d-none d-md-block d-lg-none"></div>';
}
if ($key % 4 === 0) {
$decks .= '<div class="w-100 d-none d-lg-block d-xl-block"></div>';
}
$key++;
$val++; // FR incremente compteur image
}
$val--; // FR retabli nb images
$sol=(4-($val % 4)); //FR nb images a completer
while ($sol <> 0) {
$decks .=
'<div class="card mb-4">' . //FR
'<div class="card-body">' . //FR
'<h4 class="card-title text-center">' . //FR
'</h4>' . //FR
'</div>' . //FR
'</div>';
$sol--; //FR
}
return $decks;
}

Novaslash
Posts: 4
Joined: Mon Jun 29, 2020 6:00 pm

Re: problem when I display the image categories on the main page.

Post by Novaslash » Tue Jun 30, 2020 9:06 am

Hello blondin62,

I have the same concerns as you and it is not very nice to have a huge category compared to the others.

I found the file in question but it doesn't work. I tried adding the // FR lines or completely replacing the part concerned, but in any case I come across a blank page as soon as I validate the changes.

Can you help me please

Edit: Well, I tried to copy / paste and there, it works very well. Thank you for your code :)

blondin62
Posts: 34
Joined: Sun Mar 11, 2018 11:06 am

Re: problem when I display the image categories on the main page.

Post by blondin62 » Fri Jul 10, 2020 10:35 am

hello

very good
and for // FR; in fact these are the initials of my first name :D .
I use this system when I modify a script that I did not write, very useful if I have to go back

Post Reply