WordPress.org

Ready to get started?Download WordPress

Forums

Widget Requests (11 posts)

  1. mythusmage
    Member
    Posted 8 years ago #

    1. A script widget. A widget one can use to install a script or scripts in a sidebar with widgets installed in it. This including scripts for plug-ins that use such.

    2. Alter the text widget option on the widget configuration page in Presentations so the admin can enter a number, instead of choosing from a list of number that could prove a bit too limited. (Believe me, somebody's going to find a use for more than 9 text widgets.)

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    Re: #2 -> Just edit the widgets.php file to make the possible number higher.

    -In widget_text_setup(), change the number 9 to a higher number in the "if" check and assignment.
    -In widget_text_register(), same change for the if check and assignment, and also change the 9 in the for loop to the same higher number.
    -In widget_text_page(), change the number 10 to be the same higher number plus one. So if you are upping the possible number of items to, say, 20, then you'd put 21 here.

    That's all there is to it. It's a trivially simple hack, really.

  3. headlessspider
    Member
    Posted 8 years ago #

    i've been looking for something link conditional widgets. this widget appears in the home, that widget appears in the home and the archive, and that widget appears only in a single post...

    i think this would be done in the widgets.php itself...

  4. Nah, you can do it without any plugin core editing.

    Just take whatever widget you want to customize and only have it return data for the pages you want using the standard conditional tags.

    It'll be active on all pages, but it'll only display something on the pages you want.

  5. headlessspider
    Member
    Posted 8 years ago #

    i get what you mean. what i see in my head is i want to have text3 display only on home page as well as the rss widget. i don't want to have them display in the single pages or the archive pages.

    but your suggestion is also interesting. when you said,
    "have it return data for the pages you want using the standard conditional tags" do you mean i can have php code inside which can conditionally display this or that depending on the page...?

    hmmm... which means that there's this widget (phpexec or execphp or something) that can have php code run in a text box....

    but what about the title of the widget?

  6. You'd have to make a custom widget and at the beginning of the function, check to see if it's a page you want or not. If not, stop there and don't output anything.

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    You could do it with the ExecPHP widget, but yes, the Title is a problem. Short of making a custom widget, I'm not sure of any good way to do it.

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 8 years ago #

    Actually, you could use two ExecPHP widgets to do it. It's a bit of an ugly hack though.

    Put one PHP widget above the widget you want to be conditional, and another below it. The PHP in the top one will be:
    if (!show_condition) { echo "<!--"; }
    The one below the widget you're hiding will be similar:
    if (!show_condition) { echo "-->"; }

    Basically it comments out the surrounded widget entirely if show_condition is false. So you have to check the conditions you want to show the widget both times by replacing show_condition, of course.

    Not the best solution, admittedly, but it might work on some sites until somebody comes up with a better way.

  9. Bah, I'll just make a configurable conditional widget next week when I have some free time. :P

  10. headlessspider
    Member
    Posted 8 years ago #

    8D. thanks!

    i'll try to look into the code and see how i can mess it up...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags