Search code examples
phpdrupal-7drupal-theming

Drupal 7 how to add content in custom theme


I am developing my custom theme in drupal 7.

I have .info , page.tpl.php and style.css file.

I want to add content (from admin panel article and other contents) in my theme.

How will I do this ? I have added print render($page['content']); in page.tpl.php but it doesn't work.


Solution

  • You need to declare the regions in .info file,

    name = themename
    description = Your theme description.
    version = 7.x
    core = 7.x
    stylesheets[all][] = css/style.css 
    
    scripts[] = js/yourscript.js 
    
    
    regions[left] = Left sidebar
    regions[right] = Right sidebar
    regions[content] = Content
    regions[header] = Header
    regions[footer] = Footer
    

    then clear the cache tho affect the changes.

    You can use the same <?php print render($page['content']); ?> for displaying the content in page.tpl.php

    After that go to admin-> structure->blocks

    Assign "main page content" to the "content" block

    More detailed documentation here.

    Please follow the folder and file naming structure.