• I’ve got the Image Headlines plugin working beautifully for post titles, I’m quite happy with it.

    I would like to use it to generate the titles of sidebar widgets. I’m familiar with widgetizing themes, but I’m not sure why this isn’t working.

    This is how you make any text run through the plugin: <?php echo ImageHeadline_render( 'Whatever text','formats' ); ?>

    Here’s my functions.php code (note that I’ve changed single to double quotes to avoid escaping):
    <?php
    if ( function_exists("register_sidebar") )
    register_sidebar(array("name"=>"Sidebar 1",
    "before_widget" => "",
    "after_widget" => "",
    "before_title" => "<?php echo ImageHeadline_render( '",
    "after_title" => "','' ); ?>",
    ));
    ?>

    When I use that, nothing is displayed for widget titles, but here’s what’s in the source:
    <?php echo ImageHeadline_render( '
    about me
    ','' ); ?>

    So it seems like it’s not parsing the PHP that’s within the PHP. Does anybody have ideas on how to get this working?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    It’s not working because it wasn’t made to do that. You’re trying to put PHP code into a variable and then have it run that code instead of echo the content of the variable. Won’t work that way.

    You might be able to write a plugin to do it, but it wouldn’t be very straightforward. It would have to use the PHP Output Buffering functions (ob_start and such) and a special identifier in the before_title code, to catch the titles, then it would need to replace these with the relevant ImageHeadline_render output. Not particularly the best way to do it.

    The reason this is so difficult is that the title is actually output by each widget itself, so to change how it outputs that title, you either have to change every widget, or find the titles and replace them after the fact.

    Thread Starter etoile

    (@etoile)

    Thanks for the information, I was trying various random tweaks with the PHP and it wasn’t working. I’m going to play with some alternatives, if I get this to work I’ll come back and say so. Thanks again!

    Thread Starter etoile

    (@etoile)

    I managed to do it, with the ALA Dynamic Text Replacement script. It’s not pretty, but it does achieve the goal of images created on-the-fly from text, and it can be made to match the Image Headlines output.

    <?php
    if ( function_exists("register_sidebar") )
    register_sidebar(array("name"=>"Sidebar 1",
    "before_widget" => "<br />",
    "after_widget" => "<br />",
    "before_title" => "<img src='https://www.domain.com/path/to/heading.php?text=",
    "after_title" => "' />",
    ));
    ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Compatibility between Image Headlines plugin and Sidebar Widgets’ is closed to new replies.