0

I created a content type Carousel. I created a region Huge.

On the front page, I want the content type to be placed in the region Huge.

Current process:

  1. Create content
  2. Specify publish to front page.

Even though I specify this:

render($page['carousel']).

All of the content is being loaded in:

render($page['content']).

What is the drupal way of doing this on the front page?

The use case is for marketing to create new Carousel content type >> publish to front page >> the HUGE region is updated with new content.

This should be different than regular blog's posts that appear on the front page.

Thanks for any help! noah

2

You can use Views module to create a block and place that block in your custom region

  1. Here is the step by step process to create a slide show with slide show module
  2. And placing block in the region can be done here admin/structure/block

To create custom block and template

/**
  * Implements hook_theme().
 */
function YOUR_MODULE_theme() {

$theme = array();

$theme = array(
    'my_custom theme' => array(
        'variables' => array('items' => array()),
        'template' => 'my-custom-theme'
    ),
return $theme;
}
/**
* Implements hook_block_info().
*/
function YOUR_MODULE_block_info() {
   $blocks = array();
   $blocks['slideshow'] = array(
   'info' => t('Block Name'),
);
return $blocks;
}
/**
 * Implements hook_block_view().
*/
function YOUR_MODULE_block_view($delta = '') {
   $block = array();
  switch ($delta) {
        case 'slideshow':
        $block['subject'] = '';
        $block['content'] = _YOUR_MODULE_slideshow_callback();
        break;
     }
   return $block;
 }
function  _YOUR_MODULE_slideshow_callback() {
  $result = "Your query to fetch content";
   foreach($result as $row){
       $items[] = $row;
       }
   $output = $output .= theme('my_custom theme', array('items' => $items));;
    return $output;
 }

and write html code for your slide show in my-custom-theme.tpl.php file

  • Thanks for the tip, but i'm actually planning to use jssor for the slideshow, any suggestions for doing it without views? – noah Aug 12 '15 at 5:30
  • I updated my answer, to create custom block instead of views.. – Bipin K Aug 12 '15 at 5:52
  • I think this is what I needed I print_r($page['customregion'] and my content type is not being loaded in the region. I think this is due to when you create a custom block via the UI, it forces you to add a 'body' value, instead of saying 'for this block, use this content type' So what I need to do is create the content type, and assign it either to a block in the region, or assign the content type to only appear in that region – noah Aug 12 '15 at 6:01
  • I think your hook_block_view is what I needed to place the content type inside of the block, which I can then place in the region. I'll test out tonight/tomorrow and confirm! thanks again noah – noah Aug 12 '15 at 6:03
  • You are right, you can render the block in your template file too , – Bipin K Aug 12 '15 at 6:06
0

You can done it using editing template. Render your Carousel content in Huge region of page--front.tpl.php.

  • This is exactly what i'm trying to do: however, when I attempt to render the carousel region: render($page['carousel'] nothing shows up, the content is actually loaded in $page['content'] – noah Aug 12 '15 at 5:31
  • Do you want to show enitre nodes of that content type or a single node..?? – Abin Aug 12 '15 at 5:46
0

Just follow the below mentioned steps:

  1. Make one block with content type 'Carousel'.(You can make simple block from views.)
  2. Goto block section. Select 'Huge' region. Then In block configuration, jump into visibility settings, In that go to Pages section, And select show to specific page and add in that text area.

That can solve your problem.

  • how would I do this without views module? I've defined the region via theme.info, it shows up in the UI i've created a block via the UI, I created the content type and specified it is only available for the block but the content still shows in $page['content'] and NOT $page['carousel'] I think I need to remove it from $page['content'] and force it to render in $page['carousel'] – noah Aug 12 '15 at 5:32
  • You can create your custom block using Code. And then Once you will create that block, That block will be listed out in Block section, You need to set the region as 'Huge'. Thats it. Instead of removing $page['content']. Remove your $page['carousel'] first and try to render it with block specific tpl file. – Viraj Aug 12 '15 at 5:34
  • I'll try to create the block programmatically, and see if that fixes the issue, but i've already placed the block and placed it in the region, but content type that is assigned to the block shows in $page['content'] instead of the block – noah Aug 12 '15 at 5:36
  • 1
    Try this. function hook_block_list_alter(&$blocks) { $node = menu_get_object(); // list of all block deltas u want to apply this $block_delta = array('deltas'); foreach ($blocks as $key => $block) { if (!empty($node) && $node->type == 'page' && in_array($key, $block_delta)) { unset($blocks[$key]); continue; } } } – Viraj Aug 12 '15 at 5:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.