2020-05-14, 00:48:52
(2020-05-13, 21:24:23)Felix Wrote: Also this way contributes to better separation of code and html layout
Yes, that's good idea. It was a good decision to try to separate the markup from the logic! You can even improve it by letting ItemManager render the markup, so you can focus completely on the script logic...
The only thing I notice now is that you add your CSS directly into the <body>, which might not be optimal because they should be in the <head> area.
It would be even better if you use GetSimple native functions like "get_header()", "get_page_content()" and "get_footer()" to integrate your script into the CMS.
It is also a better option to use "SimpleItem" objects instead of "Item" objects, because the execution time would be even faster. It is also recommended to physically resize the images, i.e. use the thumbnails and load the large images on demand.
Here I have written an example how you can do it (I think it should be compatible with your script): https://gist.github.com/bigin/cb1c58b6b3...56eeac3443
The example above contains only 3 functions that you can add to your "functions.php" file, note that your template must contain "get_header()", "get_page_content()" and "get_footer()" methods.
1. The function "getTemplate()" retrieves your markup and can be customized. It contains variables like [[URL]], [[CONTENT]] etc, which are replaced with values.
2. The function "getResizedUrl()" takes care of creating the thumbnails.
3. And the function "photobox()" contains the logic.
The funny part is that the script works like a plugin, but is not really one.
Try it out, take it apart, maybe you'll find something useful there. Have fun! ;-)