0

I have a front page view of articles that are displayed as trimmed as well as a sidebar block. This is all fine I have my layout all good. The issue is, if I click on an article to go to it's full page view then the article retains the css class from the front-page so I am stuck with a 70% full page article.

The main issue is that both my articles and latest articles (sidebar) use the same class name "content". I tried to edit templates in order to override this but to no avail. All blocks use the "content" class which makes it uneditable!

edit in fact every block I have uses the class="content"!

Any help would be appreciated! Cheers!

0

Surely you can either define different classes for the teaser and fullpage views of your content type using templates, edit the views template or define your css using the class .front or .node-type-article ?

For 1) create a node--content-type-name.tpl.php file and use the if (!$page) { // teaser view switch to output a different class or template.

For 2) create a views-view-unformatted--view-name.tpl.php file and wrap it in a different class

For 3) use the built in drupal classes that are outputted into your themes body tag in your themes html.tpl.php file with <?php print $classes; ?>. Edit your css to specify your style usinf .front .article {} .not-front .article {} etc ..

Or edit your block.tpl.php file and remove the class .content

  • ok I tried to change in block.tpl to <pre><code><?php if (!$is_front): ?> <div class="content-front"<?php print $content_attributes; ?>> <?php print $content ?> </div> <?php else: ?> <div class="content"<?php print $content_attributes; ?>> <?php print $content ?> </div> <?php endif?></code></pre> If I look at the unformatted-trending-topics file this is where it outputs the class: <pre><code><div<?php if ($classes_array[$id]) { print ' class="' . $classes_array[$id] .'"'; } ?>></code></pre> what should I put? – GroovyMotion Mar 22 '14 at 14:03
  • sorry formatting the code in here doesn't work – GroovyMotion Mar 22 '14 at 14:11
  • the issue is that a wrapper doesn't work on this particular tpl because it's already rows. <?php foreach ($rows as $id => $row): ?> – GroovyMotion Mar 22 '14 at 14:22
  • what about the template for the content type, rather than using the !$is_front on the block template or editing the views template? I usually set up 2 different templates for the teaser and the full page views. This is hard to go on from the info you've given. Do you have a link? – tecjam Mar 22 '14 at 14:37
  • and in the view temnplate you could wrap <div class="myviewclass"> <?php foreach ($rows as $id => $row) { print $row; } ?> – tecjam Mar 22 '14 at 14:39
0

I have finally found the culprit! It's the pager that for some reason decides to take 100% of width, so it forces the sidebar to break apart! :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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