Best way to create block that has variable parameters?
Permalink
I have a block that I am using on a photo site that I am building.
This block creates an image zoomable to a larger image using a lightbox called FancyBox (thanks Jordan for your block which gave me the base for my modified block).
Now with most images the basic block I am using is just fine. But on occasion I need it to display an image which is either very tall or very wide (or both) such that having scrollbars appear on the screen would be nice (instead of the FancyBox default of forcing the image display to fit inside the browser viewport).
There are only two settings to FancyBox that need to change for this difference to be implemented.
So most of the block, probably 99% of it, will remain the same except for the change to two lines of code inside one Javascript function that presently sits at the end of the view.php file of the block.
Rather than creating a whole new block and calling it something like "Page Image with Scrollable Zoom" as opposed to "Page Image with Zoom" I am wondering if there is a less troublesome way of having a block use different settings for some of it's internal parameters?
One thought that came to mind is perhaps having the block accept different parameters on an edit. Then when the Add button is pressed having the block write out the variable parameters to a text file inside the block directory.
When a View is again called for on the page, then having the view.php file open the text file and using the variable parameters found there instead of using some hard coded parameters which are presently found inside the view.php file.
How does that sound? Anybody got any ideas as to how best to do this kind of thing?
Carlos
This block creates an image zoomable to a larger image using a lightbox called FancyBox (thanks Jordan for your block which gave me the base for my modified block).
Now with most images the basic block I am using is just fine. But on occasion I need it to display an image which is either very tall or very wide (or both) such that having scrollbars appear on the screen would be nice (instead of the FancyBox default of forcing the image display to fit inside the browser viewport).
There are only two settings to FancyBox that need to change for this difference to be implemented.
So most of the block, probably 99% of it, will remain the same except for the change to two lines of code inside one Javascript function that presently sits at the end of the view.php file of the block.
Rather than creating a whole new block and calling it something like "Page Image with Scrollable Zoom" as opposed to "Page Image with Zoom" I am wondering if there is a less troublesome way of having a block use different settings for some of it's internal parameters?
One thought that came to mind is perhaps having the block accept different parameters on an edit. Then when the Add button is pressed having the block write out the variable parameters to a text file inside the block directory.
When a View is again called for on the page, then having the view.php file open the text file and using the variable parameters found there instead of using some hard coded parameters which are presently found inside the view.php file.
How does that sound? Anybody got any ideas as to how best to do this kind of thing?
Carlos
A user of the block could also just go in and edit the variable parameter values inside the plain text file directly without having to log in and otherwise fiddle with trying to edit values inside a database table.
Lastly all things block related would be compartmentalized inside the block directory.
Hmmm...I wonder...if storing things inside mini-text files inside block directories might be better overall than using the C5 mechanism of storing block bits and pieces of data inside separate database tables?
I'll have to play around with that.
That would speed up page rendering I think. To not have to access the MySQL database at all from various blocks on a page.
Carlos