WebsiteBaker Support (2.13.x) > Modules
New photoalbum module
sternchen8875:
a general tip for all coders
since PHP 8.x the declaration of the data-type is more and more important. a simple example, to make the code more secure is here the (int) in the front of the Section-ID
--- Quote ---$sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'mod_example` '
. 'WHERE `section_id`='.(int)$section_id;
--- End quote ---
in this case, its save, that $section_id must be a integer value - important for possible hijacking
if we need to handle a string, best solution to check this value is a intern WB-funtion, called StripCodeFromText(), that remove possible JS-Code from the submitted string and something more, like droplet-call etc
--- Quote ---if(isset($aRequestVars['cat_name']) && ($aRequestVars['cat_name'] != '')) {
$sCatName = $admin->StripCodeFromText($aRequestVars['cat_name']);
}
--- End quote ---
for a numeric value
--- Quote ---if (isset($aRequestVars['active']) && is_numeric($aRequestVars['active']) ) {
$active = intval($aRequestVars['active']);
}
--- End quote ---
good practice is it, to named own variables with the selected datatype, for example:
$i... for a integer value like $iSectionId
$a... for a array value like $aRequestVars as $_POST-array
$s... for a string value like $sCatName
$b... for a boolean
a lot of examples are in the admin-folder
sternchen8875:
Maybe not the right place to discuss about this, then sorry for that...
i build a new version of the old swift-gallery. you can select a single folder under /media and display a start picture and a row of thumb on the right side of the start pic. The output works (like the original module) without any open effect. It looks okay, if you have only 4-6 Pictures in the selected folder and thats my use for a customer. if you've more pics in the folder, it goes longer and longer in the thumblist. Maybe its better, to have a horizontale thumb-list at the bottom or a switch in the module-settings
We've also the Brax_Highslide-B-Module with the same funktion, read a single folder from media, add some picture settings, result/output is a list with thumbs, to open with a js-effect
And here, we've the project from netraam, minimal settings, but it use also the subfolders from a selected medai directory.
QUESTION: is it a good idea, to combine modules with nearly the same function to one single module?
After adding a new section, you get a select box with the 3 submodules and the rest works with switches in every module file. Every module has his own setting, his own output, his own open effects, if needed. You can add multiple sections with this 3 submodules (or with the same)
From my point possible to code, but is it a good solution for the users?
Screenshot Swiftgallery
Screenshot Pixo
Screenshot Brax-Highslide-B
dbs:
You ask whether it is a good idea to have another module with more options. I say yes. (Y)
The only disadvantage is the size of the module. Is it still installable for everyone?
sternchen8875:
--- Quote from: dbs on February 11, 2025, 06:59:08 AM ---The only disadvantage is the size of the module. Is it still installable for everyone?
--- End quote ---
my swift-version has a size (in the zip) from 167kb, it need a couple of new php-files for the backend, maybe 50kb, and it needs the other JS-files for the open-effects, highslide use 370kb (a lot of buttons via pictures), pixo use 173 kb - maybe, it goes smaller, if we use minified js.
I think, in summary 700 or 800 kb for the complete module is possible
But, I don't want to steal the work of others - Let's let netraam do his job - its only a idea for the future, for rainy day's ;-)
netraam:
At first, thanks for all the tips and rules how to properly code a module, when I have some time I will try to implement them.
I think that its not bad idea to combine all the functions of the three modules.
The most important thing for me are the subfolders. On the site of our theater company (www.restant.be/wb/pages/fotos.php), all our foto's are in subfolders. I create a subfolder for every play we preform. Because I sometimes upload 50 photo's or more at one time, I also find it useful that the images are automatically resized so i don't have to resize them on my computer. The last thing what is important for me is that the gallery is fully responsive. I have old iphone with a very small screen, so I don't like margin and borders around the photo's becaus they take a lot of space on my very small screen.
I don'y mind that you use my code, so if you are bored on a rainy day go ahead.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version