How do you separate the template of a blog block in Drupal?
In Drupal, I created a block using views. This block contains the latest blog entries. I've placed this on a specifi开发者_运维问答c page to display it as an archive. Now, as for the blog itself (for example when one of them is clicked), A blog template for it depends on node-blog.tpl.php. My problem is, when I style node-blog.tpl.php, the block I created for the archives (as it displays on the page) gets affected.
For example if I add TEST on node-blog.tpl.php, I will also get that on the block for every entry. I think it's because it is associated to a blog entry? What I want is to have node-blog styled "alone" when blog entries are viewed individually and not get the other entries on the blocks on the archive page be affected. How should I do this?
In your view you are probably using the "node" row style. This means that each blog in your block view is displayed as a full node and will be affected by node-blog.tpl.php
The easiest way to fix this is to change row style to "fields" and select the individual fields to display in the view. Then you can individually theme each field using the view's custom .tpl.php files (you can click on Theme: Information
in the view to see scanned tpl.php files).
Another way to fix this would be to select "teaser" build mode in the row style settings. Then in node-blog.tpl.php
do something like the following:
if ($teaser) {
//Display stuff for the block
}
else {
//Display stuff for the full page
}
精彩评论