Help Desk

Variable Layouts

  • Posts: 10 Topics: 5
    | Permalink

    Hi there,

    I understand that I can create a custom template for my images (thank you for this feature!) but I\’m wondering if I can take this a step further and target instances of the widget. For example, if this is the first image widget on my sidebar, use X template; if it is the second image widget on my sidebar, use Y template.

    I know this is probably a pretty custom ask, but if you could point me in the right direction, I would appreciate it!

    Posts: 11241
    | Permalink

    Hi, Colleen. Please explain what you mean by “create a custom template for my images.”

    Additionally, would you be able to share an annotated screenshot, screen capture video, and/or relevant URLs to clarify exactly what you’re asking about?

    Posts: 10 Topics: 5
    | Permalink

    Hi Cliff,

    Apologies for the rather vague post.

    I changed my image widget template (using the “sp_template_image-widget_widget.php” filter) with the following, so as to utilize the image as a background image and break out the title/text of the widget from the image (see attached):

    echo $before_widget;
                echo '<div class="square"></div>';
                if ( ! empty( $title ) ) { echo '<div class="square"><div class="content"><div class="table"><div class="table-cell">'.$before_title . $title . $after_title; }
                if ( ! empty( $description ) ) {
                    echo '<div>widget_options['classname'] ) . '-description" &gt;';
                    echo wpautop( $description );
                    echo '</div>';
                }
                echo '</div></div></div></div>';
                echo $after_widget;

    My end goal was to alternate the code, so if the widget was an even instance, show the background image portion of the code first, THEN the description, and if it was an odd instance of the widget, show the text THEN the image.

    But, I have a feeling it’s a pretty custom request and was just hoping you might point me in the right direction.

    However, I may have found another way to achieve my alternating layout, by coding in a class for even widgets, then targeting the even widgets with specific CSS styles.

    I think I’m set, but if you did have any tips, I wouldn’t turn them down! Thanks to you and the team for all the great products.

    Posts: 11241
    | Permalink

    Thanks for that additional information.

    I don’t see “sp_template…” anywhere in our code so I’m unsure how to assist here.

    Posts: 11241
    | Permalink

    Oh, sorry, I did find it in Image Widget but not Image Widget Plus.

    You can disable Image Widget and run solely Image Widget Plus. Please let me know if you don’t want to do that for some reason.

    Posts: 10 Topics: 5
    | Permalink

    Sorry– I kept trying both plugins off and on to see if I could get it to work either way and must’ve forgotten that I was able to get it with the regular (not Plus version) of the plugin.

    I think my alternative way mentioned above will suffice, but I appreciate the time.

    Thanks,
    Colleen

    | Permalink
    Posts: 11241
    | Permalink

    Sure thing; thanks for letting me know.

    If needed, please complete our Refund Request Form and link back to this thread for reference.

    Have a great day.

The topic ‘Variable Layouts’ is closed to new replies.