0

I created a content type of which there is only one node of, and i want to add to sidebar left. How can that be done? i would prefer not have to use a module to do this., thanks

2
  • i just tried this, did 'Add Block' and added some PHP that echoed out what i wanted but it printed the PHP. surely there's a way to do this.
    – TopTomato
    Jun 7, 2014 at 18:26
  • i'm just going to hardwire it to the page.tpl.php
    – TopTomato
    Jun 7, 2014 at 18:31

2 Answers 2

0

I would suggest using views for this.

  1. Create a "Content" view and choose your content type in the "Show" dropdown
  2. Uncheck "Create a page" and check "Create a block"
  3. Choose "Unformatted list" and "Full posts"
  4. Limit the block to 1 "items per page"
  5. Click the Continue & Edit button
  6. Add a contextual filter for Content: NID
  7. Provide a default argument of Fixed value and enter the Node ID of the node you want to display within the block

Optionally, you can choose to create a fields based view instead of full posts which would allow you a little more control over the layout of the nodes content within the block.

If you are set on not using ANY modules to do this then you'll want to look into https://api.drupal.org/api/drupal/modules%21block%21block.api.php/function/hook_block_view_MODULE_DELTA_alter/7 which would allow you to override a blocks output in your themes template.php.

/**
 * Implements hook_block_view_MODULE_DELTA_alter().
 */
function YOURTHEME_block_view_block_BLOCKDELTA_alter(&$data, $block) {
  $data['content'] = drupal_render(node_view(node_load($nid)));
}
0

Use Node Block. I know it's a module and you didn't want to use one, but it's lightweight and will probably do exactly what you want.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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