I've got a custom event CCK type using just the date module, basically it's a very simple events system (we've no need to go the more complex route of using the events module). I'm also using views to create a custom ordered view. It looks halfway decent I think, other than the content isn't zebra'd yet.
I've setup the stylesheets and know it works, because If I create a custom and static page using the xhtml it shows up perfectly. All that needs to happen is for the $zebra variable to spit out odd or even and it'll work. I've added:
<?php print $zebra; ?>
To my CCK content template custom teaser for my content type, right into the correct area of the style= attribute for my div. It doesn't work, and in fact upon viewing the source doesn't even spit anything out.
Does $zebra work with the CCK, content templates and views modules?
Comments
I hate to bump but it seems
I hate to bump but it seems like this should be supported somehow...
automatic
Hi dittobox..
I did something very similar recently....i.e. created an event listing using cck date module as the "time on stage" type field. Views automatically generated the zebra views for me (I used table views) so all I had to do was change the background gcolor in the css declaration for
tr.oddandtr.evento achieve the zebra effect.Are you using a teaser view to display your events?
Try the following in your event template (if you're using something like the contemplate.module to control teaser/full node/rss output) or a tpl.php layout file in your theme folder.
So your style.css will have the following declarations:
Tip: If you're using tpl.php files to split apart your teaser...the
<?php if ($page == 0) { ?>flag is what precedes the teaser content. i.e. when page = 0 it's teaser and when page =1 it's the full node view.Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Yes I am using a teaser
Yes I am using a teaser view, with a custom teaser field via CCK. I like to maintain as much control over layout and content as possible. I'm avoiding using tables since this data isn't displayed in a tabular fashion and tables in this particular instance/application introduce unnecessary code complexity.
Thanks!
quick one
I edited my earlier post with a more detailed explanation...probably as you were typing that.
The snippets I posted will let you display teaser lists of any node type (cck included) with the zebra effect.
Dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
Thanks, but that doesn't
Thanks, but that doesn't seem to work. That's what I'd already tried but the contents of the $zebra variable are empty, it doesn't print/echo anything out. I also created node-event.tpl.php, and that affects content but $zebra still doesn't work.
Any ideas?
i tried it
I just tried it ditto. it works in Drupal 5.1. (I tested the above snippets in a tpl.php file).
Post your node-events.tpl.php file with your implementation of the print zebra.I might be able to spot from that why it isn't working.
Alternatively...just below where your TITLE is declared (try it in your node.tpl.php file in case Drupal isn't picking up your other .tpl.php files), just put in this line:
<p>Zebra: <?print $zebra;?></p>and it should print odd/even in your teasers. At least, it did for me.I'm working late so I'll be online to have a look later.
dub
Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate
<div class="event <?php
I used that in content template and also used that (with the $page code you posted above and some if and endif stuff) in the node-event.tpl.php, which I deleted when it didn't work. I can rewrite if you want. I'm using the views module to sort by the date field, which uses the date module, and I'm using contemplate to make the teaser and the full node look great. With views you can't drop custom code into the page so I can't check to see if $zebra actually contains data. I tried adding it to one of the individual nodes but that didn't work.
I found this and got it working, it's actually really cool because I can start using in other places in the theme. I'd still rather not use a JS hack to make this work though.
Thanks again for your help!
You're right. $zebra doesn't
You're right. $zebra doesn't not work in contemplate.
But it does work in the tpl..
create a custom tpl based on the content type...
like
node-mycontenttype.tpl.php
It's kinda like contemplate this way.. or you don't even need contemplate when you do it this way.
Something else odd that
Something else odd that doesn't contain anything in the view is the "$node_url" and the "$node->links['node_read_more'];" array.
$links doesn't contain anything either.