Brad Padgett
Well-known member
HTML:
<a href="{{ link('misc/style', null, {'style_id': property('Dark_Switch'),'_xfRedirect': $xf.fullUri,'t': csrf_token()}) }}"><img src="{{ base_url('styles/default/BP/LightSwitch/bulb-off.png', true) }}"></a>
<a href="{{ link('misc/style', null, {'style_id': property('Light_Switch') ,'_xfRedirect': $xf.fullUri,'t': csrf_token()}) }}"><img src="{{ base_url('styles/default/BP/LightSwitch/bulb-on.png', true) }}"></a>
The code above. What it does is allow me to target specific styles in a light switch add-on (and style chooser) I have almost finished to release as a free add-on to the community. There is but one issue. I do not know how to reuse this code for 4 pairs of additional styles I want to hook up to the light switch.
If I copy the code and use again the light bulb shows 4 additional times. What's happening is it's taking the style property "Dark_Switch" and "Light_Switch" where a user would enter 2 separate style ids in style properties-> click save -> and then it would be hooked up. How can this work for more than 2 styles? Preferably a pair of 5.
My add-on is perfect for what a lot of people would like on their site. It's going to have several options. The style chooser appears right on the far right of the sub-nav. It's got up to 9 styles you can configure through style ids and the light switch also configurable in the nav bar. Style chooser part is finished and ready. My site has 5 light and 5 dark styles. For the light switch portion I cannot release it until I find out how to do 4 more.
I'm going to tag all the people who have helped me in the past. Anyone can help with the answer and If you do not know the answer then it's quite alright. I'm just anxious to finish it. I worked on it all day yesterday. @Chris D @DL6 @Sim @S Thomas @DragonByte Tech
Last edited: