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 Answers
I would suggest using views for this.
- Create a "Content" view and choose your content type in the "Show" dropdown
- Uncheck "Create a page" and check "Create a block"
- Choose "Unformatted list" and "Full posts"
- Limit the block to 1 "items per page"
- Click the Continue & Edit button
- Add a contextual filter for Content: NID
- 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)));
}
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.