If I use a custom widgetized area (for example footer) where there is only a limited number of spots for widgets (by design), can I limit the number of widgets the user may include in that specific widgetized area? It doesn't matter if the solution is at the backend or the front end. Thank you.
|
feedback
|
|
I solved this in Javascript. If you want to completely prevent it you should also do it server-side, because you can edit the widgets with Javascript disabled (try it out!). The different sidebars are checked when you drop widgets to them or away from them. If they become full, the background color changes and you can no longer drop items on them. If, on startup, the sidebar is already more than full (because you tightened the restriction), the background color becomes red. You can still drag widgets away from full widgets to make them empty again.
Please test out this code, to find ways to add or remove widgets that I missed. The "magic" in the jQuery code comes from Aman, who answered a Stack Overflow question I posted about it. Javascript:
CSS:
PHP to load them:
An attempt at a server-side check (probably not complete yet):
| |||||
feedback
|
|
Interessting Q. Didn't find out much at a brief look, but here's a guess: | |||
|
feedback
|
|
You can do below stuff in order to determine the count of widgets. Function:
I hope this will solve your doubts. | ||||
|
feedback
|
|
to help you with your question, I have a suggestion. Let's use the As a good practice and secure, firstly backup it to avoid headaches. The original Twenty Ten template code for presenting first footer widget is:
Let's change, adding some code with conditionals to limit the number of widgets allowed in that area.
What this modified code does:
count the number of widgets in that side bar and stablish some allowed limit (setten by you).
If the the limit allowed for widgets in that area was reached then it will be show a message warning that limit else the widget will be shown. So I hope I have helped with your question. | ||||
|
feedback
|
