1

I am trying to change the format of the content promoted to the front page. I want to move the display order of the title below the image. By default it's set to title, image and then Read More.

Editing the content type (manage field, manage displays) does not do anything in this regard.

Manage display: I've set the order from Image first then Body. (no effect)

Teaser: I've set it to only show the Image (body is hidden) (no effect)

I've read the docs to change the page.tpl.php to page--front.tpl.php but I don't see any options to move the title down below the image in this file. (I only see this code in node.tpl.php.)

I can move the title block under the content block and it works, but this affects all pages.

How can I change this only for the front page, so it doesn't affect all pages?

node.tpl.php

Title block

<?php print render($title_prefix); ?>
<?php if (!$page): ?>
 <h2<?php print $title_attributes; ?>>
  <a href="<?php print $node_url; ?>"><?php print $title; ?></a>
 </h2>
<?php endif; ?>
<?php print render($title_suffix); ?>

Content block

<div class="content clearfix"<?php print $content_attributes; ?>>
<?php
  // We hide the comments and links now so that we can render them later.
  hide($content['comments']);
  hide($content['links']);
  print render($content);
?>

3 Answers 3

1

There are many possible ways to customize your front page content.

One of the easiest would be to create a view with page display and set the field order as you like and give a path to the view. Now you can change your frontpage to the path of this view (Configuration > Site Information - Default front page).

If you want to go with the standard front page and rearrange in the template as you described you could use drupal_is_front_page() to have different parts of the template for frontpage and other pages.

2
  • Thanks for the `drupal_is_front_page()'. Are there any guides on how to set this up? Commented Jul 28, 2015 at 19:18
  • You can use it in if-clause like <?php if(drupal_is_front_page()) : ?> and <?php if(!drupal_is_front_page()) : ?> Commented Jul 29, 2015 at 15:56
1

The solution of Stefan Korn is good and simple.
If I'm not mistaken, there is an alternative solution, shown here, where it is recommended to use template_preprocess_node() in order to be able to work only on the file node--front.tpl.php, "while your original node.tpl.php will be used everywhere else." (quote)

0

Usually the content generated in front page has nothing to do with the page--front.tpl.php, basically the content is being rendered in content region, it is probably a list of rendered entity in your front page with teaser display or in some cases it might be a views list which I doubt it. unless you provide more info about what and how you already displaying your content, there's nothing much we can do to help you!

4
  • I am using teaser, but I don't see any options on display order in that menu. In my teaser settings, I am only showing image. Body is being hidden. And in Manage display I've set the order from Image and Body but this has no effect on the front page. Commented Jul 27, 2015 at 22:08
  • when you hover on your content row, you should be able to see a smal cog, it's called Contextual filter, click on it then click on manage display see if from there you can fix your issue, also you might wanna try to use Display Suite module, it's much easier to use. note that you first need to activate the Display Suite module by creating a layout of it in Manage Display settings
    – Sohail
    Commented Jul 27, 2015 at 22:10
  • Yes, I've checked this, there's no option there to change the display order. The manage display in structure>content type>manage display has no effect on the front page as I mentioned. Commented Jul 27, 2015 at 22:12
  • Again, try to use Display Suite module, you can use it to ease your pain.
    – Sohail
    Commented Jul 28, 2015 at 7:30

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.