[support] D7 Adding content to an empty region from template.php

Jeff Greenberg listmail.ayendesigns at gmail.com
Sat Jun 2 02:56:03 UTC 2012


I'm going around in circles :)
Ok, so I created variables in template_preprocess_region(). I print the
variables in region--featured.tpl.php. Nothing shows up. If I print a
string in the same template, nothing shows up. If, however, I create a
block and assign it to that region, then the template fires and everything
prints.

So, how do I get content into the region from template.php so that the
region template fires?

Also, I notice that template_preprocess_region fires for every region with
content. In order to not have the assignments I do in it fire for every
region on the page, I need to check $vars['region'] ... the problem,
though, is the same as with the region template file... $vars['region']
contains 'content', 'sidebar first' and 'footer' during the page creation,
but never my region...I assume because my region doesn't have content.
Seems like a catch-22.

On Fri, Jun 1, 2012 at 2:34 PM, Benj Fredrick <benj.fredrick at gmail.com>wrote:

> i'm just setting some $vars['custom_variables'] - and then printing them
> in a region tpl file
>
> -Benj
>
>
> On Fri, Jun 1, 2012 at 12:25 PM, Jeff Greenberg <
> listmail.ayendesigns at gmail.com> wrote:
>
>> I did try using that function, but two things, into which structure do
>> you deposit the content, and if I display the region name, it seems this
>> doesn't fire for the empty region.
>>
>> Sent from my iPhone
>>
>> On Jun 1, 2012, at 10:53 AM, Benj Fredrick <benj.fredrick at gmail.com>
>> wrote:
>>
>> I don't know that it's the Right Way or the Best Way, but I have used
>> template_preprocess_region() to add content to an empty region from
>> template.php.
>>
>> hope that helps,
>> -Benj
>>
>>
>> On Thu, May 31, 2012 at 5:54 PM, Jeff Greenberg <
>> listmail.ayendesigns at gmail.com> wrote:
>>
>>> I was asking a slightly different question in the themes list, but I've
>>> narrowed down my issue, and believe it's more of a support question than a
>>> theme development question.
>>>
>>> I am trying to add content to a region from within template.php. The
>>> region has no content prior to doing this.
>>>
>>> I have tried drupal_add_region_content() from template_preprocess_page,
>>> template_preprocess_html and template_preprocess_region.
>>>
>>> I've also tried just making an assignment to
>>> $vars[page][my_region][my_section_name][content][#markup] from the same
>>> functions.
>>>
>>> Nothing results in output. Do I have to do it using hook_page_build from
>>> a module?
>>>
>>> --
>>> [ Drupal support list | http://lists.drupal.org/ ]
>>>
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>
>
> --
> [ Drupal support list | http://lists.drupal.org/ ]
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20120601/7e6777d0/attachment.html 


More information about the support mailing list