• Resolved Jeff Cohan

    (@jdcohan)


    Great plugin, Otto.

    I’m sure this question is way beyond the scope of your support responsibility, but I thought you might have a suggestion.

    I’m using the plugin (in the Primary Sidebar widget area) to dynamically generate a “local menu” of pages in a section (i.e., children of the current page). I can further explain, if necessary. But the issue is that in some cases, there IS NO local menu to display. However, the aside section is still generated in those cases, and the sidebar presents as an empty section element within the aside with class sidebar-primary, with the styling of .sidebar-primary.

    I’d like to be able to hide the section if my php code returns nothing.

    Would the best approach be to write a little jQuery function (and I’m about to betray how little I know about jQuery) that looks for a section with class “widget_execphp” that contains a div with class “execphpwidget” that has no innerHTML, and then hide the section?

    Jeff

    https://www.ads-software.com/plugins/php-code-widget/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    www.ads-software.com Admin

    Actually, it would likely be better to take your PHP code, and write your own plugin with a custom widget to support your use case.

    Making a widget isn’t difficult. Making a plugin isn’t difficult. And you already have the PHP code to generate the output.

    Take a look at the plugin. It’s less than a page of code:

    https://plugins.svn.www.ads-software.com/php-code-widget/trunk/execphp.php

    Take that code, rename the plugin, rename the classes and the first function in it to something else. Change the descriptions and the classnames.

    Modify the widget() function to use your code instead. If you don’t need any configurable options, then flat out remove the update() and form() functions, as you won’t need them at all.

    The PHP Code widget is a handy time saver for quick things. But if you’re writing custom code anyway, then write a custom plugin with your code and your widget. It’s dead easy to make a widget.

    Thread Starter Jeff Cohan

    (@jdcohan)

    Thanks for the quick and comprehensive response, Otto. I’ll definitely consider what you’ve suggested. Makes lots of sense.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hiding an aside section if PHP returns no output’ is closed to new replies.