Looking for a dedicated hosting solution with 24/7/365 U.S.-based, English speaking phone support? Visit Rackspace for a reliable, managed hosting solution that will let you focus on the bottom line - your business, while they make sure your website stays online.
Big Stock Photo offers nearly 3 million stock photos to choose from - royalty free, starting at $1 per photo. We're able to extend free photo credits to our visitors for a limited time. Click here and use promo code HW2333 when you sign up.
Getting teasers to work in CCK has been a long-running issue in the Drupal community. The current approaches are summed up nicely by warco in his post on Developing CCK teasers the right way. I attempted nearly all those approaches. While they all have their merits, there are problems with all of them. The patches get outdated too quickly as CCK gets updated, the Content Templates approach has too much overhead for me, but the last approach, Nick Lewis' approach via PHP Template, is quick and easy and does not affect the code in a way that will force developers to make rollbacks once CCK finally gets integrated teaser support.
The version that ultimately worked the best for my needs is based on Nick Lewis' approach, with slight modifications lent by the "passing drifter, Manu." Here's the code to place in your custom theme files:
template.php
Simply replace "content_news" with your content type, you may add as many case statements as you need for your different content types. Place the code for node.tpl.php right inside your
tag, and make sure to replace the statement.
node.tpl.php
n/a
A common complaint from this point on was that the "read more" links were not showing (which allow you to access the full node of the teaser). Instead of taking the approaches suggested on Lick Newis' thread, which provide a separately generated "read more" link (which needs to be placed and styled accordingly in order to fit your theme, and can be a hassle), I simply installed the excerpt module (browse to Drupal Modules, select your Drupal version, and search for "excerpt"). Voila
the read more link integrates with our teaser. The only thing that remains to be done is adding a comparison between teaser and body so the link doesn't generate if the entire text is presented. If you have any questions/ comments about my approach please post below.
All Content © 2005 - 2010 Contract Web Development, Inc. All Rights Reserved. Privacy Policy | Terms of Use | Powered by Drupal
Very cool - except the
Very cool - except the teaser doesn't show up for anonymous users. Any ideas?
Input Format
The problem is probably occuring because
print check_markup($cck_teaser, $field_body[0]['format']);
is formatting the output to an input format that is not accessible to anonymous users. Change the line to simply
print $cck_teaser;
should solve your problem.
Sweet! That did it :) thx!
Sweet! That did it
thx!
Thank you!
I'm adapting your code for my content type on my personal blog. Seems it's working, but I need some time to polish all. Soon it will be ready
-- Alex