Hi,
hi - this questions regards displaying specific CCK values in a custom calendar view. Because the Week View is integral to my usage, this is build in 4.7
it seems there's not much theming information for CCK output via Calenar. None of the standard node-content_example.tpl.php, or field-field_my_field.tpl.php solutions work (unless i REALLY really don't get it), as all the info must be passed through the calendar theme engine.
my end goal is simple: theme specific cck fields in a given calendar view. The values are already assigned to the view (they end up comprising the teaser), BUT they must each be themed a little differently, which when blocked all together as teaser does not work.
in order to get the week view to display all this info in the first place required some template.php theming. it looks like this:
function mytheme_calendar_node_week($node) {
$output .= '<div class="calendar weekview">'."\n";
$output .= theme('calendar_stripe_stripe', $node);
// the switch calculates the time format
switch ($node->calendar_state) {
<b>...unnecessary for this question and thusly omitted</b>
}
$output .= '<div class="title">'. l($node->title, "$node->url", array('title' => t('view this item'))) .'</div>'."\n";
<b> $output .= $node->teaser;</b>
$output .= '<div class="links">'. theme('links', $node->calendar_links) ."\n</div>";
$output .= '</div>' . "\n";
return $output;
}
it's the line $output .= $node->teaser; that contains all the cck field values all wrapped up into one teaser element.
since it is the $output that seems to power all the other displayed elements in the calendar, i assume what i'm looking for would be something like:
$output .= $field_one_field[0]['value']
$output .= $field_two_field[0]['value']
$output .= $field_three_field[0]['value']
naturally however, this is the not the proper syntax.
what is the magic word for:
Print THIS field HERE in a calendar view so that i might THEME it individually
it looks like this: http://dyss.net/artnet/files/cal-ex.gif
and i want to... make every line a different color or something
???
thanks!
best, isaac
Comments
My understanding of how it works.
My understanding of how it works is that you specify the fields that will show by the fields you select as part of the view. If you need control over how those fields are formatted I would override
See the part under the comment 'For other views, construct a teaser out of the provided fields', that is where you could add additional formatting as needed.
sort of how i got started...
hi nevets,
thanks for your response. the fields i want to show are specified as part of the view (what they don't tell you is that this method does not work for the week view, thus my overriding of the theme mentioned in my post). the guts of this function, i do believe, is what creates the teaser out of each of these individual fields - making one teaser variable out of the many smaller fields. BUT this doesn't allow me to theme each one individually - at least not as i can tell, which leads me to think that outputting individual fields is the way to go.
i guess?
or how could i consider reworking the
theme_calendar_calendar_nodefunction to output the teaser in parts or something? or stripes?best, i
I would start with theme_calendar_calendar_node
I would start with theme_calendar_calendar_node and in particular
I would start by make a class name from the field name and adding it to the div.
$field->NAME THAT FIELD
excellent - i get it...
i'm still faltering on the syntax tho...
$node->teaser .= '<div class=' . $field . '>'. $field .'</div>';isn't quite it. i just need to be able to create a different class for each field type... almost!any other awesome tips?
A couple of thoughts
I do not have a 4.7 install to try this on do this may be off a bit, try changing
to
on the assumption $node->fields is indexed by field name.
Then change your line above to
Note that besides using $field_name for the class I add double quotes around it.
wow
you have been so kind and helpful on this. i'm pretty sure that totally nailed it!
thanks so much! back to o'reilly's php cookbook for me.
best regards, Isaac
str_replace
NEVERMIND - tired eyes... everything works...
i'm overthinking and underthinking at the same time. disregard this next part...
ok - another hitch - looks like the underscores in the class names must be replaced w/ dashes... naturally i can't figure out how/where to implement this guy (if he is right anyway...?)
$field = str_replace('_', "-", $field);hope that's the last thing...
thx! i
For anyone ready along
For anyone ready along
$field = str_replace('_', "-", $field);should be$field_name = str_replace('_', "-", $field_name);