CCK Pager and CONTENT_HANDLE_MODULE.

peximo - November 7, 2009 - 15:09
Project:Content Construction Kit (CCK)
Version:6.x-2.6
Component:General
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Hi, some time ago I created a module http://drupal.org/project/cck_pager for paging multiples cck field values.
The module reimplements all the formatters defineds by all the others CCK module and manages the multiplicity by its own.
The module works, but I realized that all the values of the field are placed in a single div wrapper: this breaks the default style; the problem is that even if I manage the theming replicating the default one ('content_field') the result is included in a row.
Eg:

<div class="field-items">
  <div class="field-item odd">
    <div class="field-item odd"> 1 </div>
    <div class="field-item even"> 2 </div>
    <div class="field-item odd"> 3 </div>
    <div class="field-item even"> 4 </div>
    <div class="field-item odd"> 5 </div>
  </div>
</div>

By debugging I found that the theme function used to render the field is provided by the #field property that is set to 'content_field'.
So I have resolved the situation at the moment in the dev version of the module with a small trick: the theming function changes the field type with a custom field type so we can call an "intermediate" theming function, which, after pagination, sets the element's #single property to TRUE and calls theme('content_field') restoring the normal theming flow.
I read #323460: multiple values and CONTENT_HANDLE_MODULE but my case is a bit special because CCK Pager defines neither the field nor the widget.
I'd like to ask you if this solution seems acceptable or whether there may be more elegant and correct solutions.
Thanks for your patience.

#1

markus_petrux - November 7, 2009 - 17:08
Status:active» fixed

Duplicating formatters looks overkill to me. There's more than one way to do things, so I would try to explore more options, then evalute pros and cons of each one. Do not proceed unless you have been able to evaluate 2 or 3 alternatives to a problem.

One possible way that comes to mind would be using MODULE_preprocess_content_field() or try to play with the Drupal theme registry to alter entries for existing formatters, and see how far you can go from there.

And well, if you find one approach that works, then stay with that one. At this time, I doubt things will change too much in CCK for D6.

#2

System Message - November 21, 2009 - 17:10
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.