• How about building in the ability to specify the widgets you want to display on each page of your site from the dashboard? For example, I could see it being handy to display all widgets on the blog’s front page and only a few of them on all the others. It would be very useful for the likes of WordPress.com and any other multi-site instances of WordPress that there may be where users cannot have access to theme code or upload themes of their own choosing.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    Here’s an idea I’ve used before –

    With a little JavaScript you could toggle visibility by using comment tags in the page content.

    You could use a comment tag like this in your page content –
    <!-- !widget-1 -->

    Then use js to toggle the visibility of widget-1 –

    p = $(this).html().split('!widget-1');
                    if(p[1]){
                      $('.widget-1').hide();
                    }

    You can create any number of tags which would toggle specific widgets.

    Perhaps one benefit to this method is that search engines would still index the widget content even if it’s not visible.

    Just be sure you’re not reading the tags from page visitor-submitted comments. ??

    I made a jQuery plugin to do something like this. Except you can use any HTML tag’s rel attribute to hold a list of object id’s or class names, like this –
    Head:

    <script type="text/javascript" src="https://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript" src="jquery.jlvisi.js"></script>
    
    <script type="text/javascript">
    	jQuery(document).ready(function () {
        $('#visibility').jlvisi();
    });
    </script>

    Post or page content:
    <span id="visibility" rel="!.widget-1,!.widget-2,*.widget-3"></span>
    In this example, the span tag could be added to the post or page to control the visibility of the widgets listed in the rel attribute. The ! exclamation mark preceding a class name indicates the object will be hidden. The * asterisk preceding a class name indicates the object will be visible.

    You can get the plugin at my website https://jasonlau.biz/home/jquery/jlvisi-a-jquery-plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Select widgets by page’ is closed to new replies.