[themes] Corralling a stray button

Jeff Greenberg listmail.ayendesigns at gmail.com
Wed May 30 23:40:06 UTC 2012


That worked, to a point. The button stays with the text doing that, but, it
introduces another problem.
In this theme, in the page template, the regions, including the one I'm
using, are coded like this:

    <?php print render($page['featured']) ?>

and what happens is, after I create the output I want:

      if (drupal_is_front_page()) {
        global $my_theme_path;
        $featured_image_path = $my_theme_path .
'/files/frontpage_feature.png';
        drupal_add_css('div.region-featured {background-image: url(' .
$featured_image_path . ')}', 'inline');
        $vars['my_button'] = theme('button', array('element' =>
array('#attributes' => array('id' => 'my-button'), '#button_type' =>
'button', '#value' => t('Test'))));
        $vars['feature'] = '<div id="my_wrapper"><div id="welcome">some
text<div id="signup">' . $vars['my_button'] . '</div></div></div>';
      }

I then have the problem of trying to get it to print within the region. If
I change the line to:

    <?php print render($page['featured']) . $feature; ?>

I get the above content printing, but without any markup for the 'featured'
region, because this content does not get added to the region, and the
region contains no other content, no markup appears for it.

On Wed, May 30, 2012 at 12:26 PM, Laura Scott <pinglaura at gmail.com> wrote:

> Have you tried defining all the markup in template.php to be included in
> output, and simply calling the variable in your tpl?
>
> Laura Scott
> via tablet
>
> On May 30, 2012, at 5:46 AM, Jeff Greenberg <
> listmail.ayendesigns at gmail.com> wrote:
>
> So here is what I discovered. It is something that Drupal is doing in
> rendering. Here is an uncomplicated html example that works fine in a .html
> file
>
> <div style="position:relative">
>     <div style="position: absolute;top:100;">
>         This is a test
>         <input type="button" value="test" />
>     </div>
> </div>
>
> In Drupal, my outer div is the region, which I mark as relative
> positioning in the css. The inner div is a block, which I mark as absolute
> positioning in the css. The block appears correctly. The button, whether I
> create it via $mybutton=theme(button), or create it via $mybutton="<input
> type=button>, I have tried printing the variable from the template and
> inside the block, and the markup always ends up like this:
>
> <div>
>   <div>
>      block stuff
>   </div>
> </div>
> <input>
>
> On Tue, May 29, 2012 at 8:27 AM, Carl Wiedemann <carl.wiedemann at gmail.com>wrote:
>
>> Global variables are not necessary and should be avoided.
>>
>> Does it *visually* appear outside of the enclosing divs, or are you
>> talking strictly about the markup? The former could indicate a mere CSS
>> error.
>>
>> Consider providing a pastebin of both the preprocess and markup to help
>> diagnose.
>>
>> Carl Wiedemann
>> Website design & development consulting | c4rl.ws
>> carl.wiedemann at gmail.com | skype: c4rlww
>>
>>
>>
>> On Mon, May 28, 2012 at 9:50 PM, Jeff Greenberg <
>> listmail.ayendesigns at gmail.com> wrote:
>>
>>> In D7, in template.php, I'm hooking preprocess_page and setting a
>>> $vars[] variable = theme_button.
>>>
>>> In a block, I have this:
>>>
>>> <?php global $signup_button; ?>
>>> <div id="signup"><?php print $signup_button; ?></div>
>>>
>>> The button appears in the page source outside of those enclosing divs.
>>>  What am I doing wrong?
>>>
>>>
>>> _______________________________________________
>>> themes mailing list
>>> themes at drupal.org
>>> http://lists.drupal.org/mailman/listinfo/themes
>>>
>>>
>>
>> _______________________________________________
>> themes mailing list
>> themes at drupal.org
>> http://lists.drupal.org/mailman/listinfo/themes
>>
>>
> _______________________________________________
> themes mailing list
> themes at drupal.org
> http://lists.drupal.org/mailman/listinfo/themes
>
>
> _______________________________________________
> themes mailing list
> themes at drupal.org
> http://lists.drupal.org/mailman/listinfo/themes
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/themes/attachments/20120530/7cda9790/attachment.html 


More information about the themes mailing list