I have encountered a couple of problems as I am configuring the ddblock module. This is my first time through the process of configuring it.
1) Image Field
I copied the preprocess function into my template.php, and it works. However, this variable, which is part of the [themename]_preprocess_ddblock_cycle_block_content function does not exist:
$result->node_data_field_image_field_image_fid
But this variable does exist:
$result->node_data_field_pager_item_text_field_image_fid
And it contains the image id that is in this CCK Image field:
field_image
I updated the code in my template.php accordingly, and that image shows up in my slideshow now.
So I'm wondering: should there really be a $result->node_data_field_image_field_image_fid present? (If so, it would have been passed in as part of $vars['content'].)
2) Can I access other views fields?
It seems that only certain predefined fields (passed in as $vars) are available in the preprocess function. There are more fields than just these in my view, but I don't see properties for them in the preprocess function.
If I want to use a different field for my main image, say "feature_image" or "main_photo", how do I do that? I mainly want to get access to more fields that I am exposing with views. Or if I want to combine a few more views fields into my display, what is the recommended way of doing that?
Thanks in advance,
-david
Comments
Comment #1
ppblaauw commented1.) It depends on the versions of filefield and imagefield what the name is of the image field (made by the content type) in the preprocess functions is.
2.) If you uncomment the drupal_set_message debug lines in the preprocess functions you can see which fields and the fieldnames your content_type/view supplies.
You can add or combine them in the preprocess functions the same way other fields are defined in the preprocess functions to be used by the ddblock theme template files.
Hope this helps you further, please let me know.
Comment #2
nadavoid commentedI'm using the latest versions of imagefield and filefield. Both are 6.x-3.0-rc1.
When I was setting this up on a live site (after tinkering on my dev site) I had a do some different things, because my field names were different. Here is a variable that I was able to use:
node_data_field_header_display_yn_field_teaser_text_valueThe strange thing about this variable name is that it consists of two field names.
field_header_display_ynis one fieldfield_teaser_textis a different cck fieldI did a dpm($result) inside the foreach loop. (I also did a dpm($vars['content']) and dpm($vars) at the top, just to see what we're working with.) So I do now see all of the fields I'm exposing the view.
These are all of the CCK fields it shows me:
So it looks like one field (field_header_display_yn in this case) is being used as a prefix before the name of each relevant field. Is this correct? Is it intentional?
Comment #3
ppblaauw commentedNaming of fields is not done by the ddblock module.
Did you manage to add and/or combine your other fields in the preprocess functions?
Comment #4
nadavoid commentedI did not rename or combine fields in the preprocess functions. To be sure, I created a new theme from scratch, and placed into it only the preprocess functions from Export_files_V1.1.zip. I uncommented the
dsmlines, and still saw the same strangely combined field names as before, such asnode_data_field_header_display_yn_field_teaser_text_value.I suppose there could be some other module or configuration that might be affecting this, but scanning over my enabled modules, I don't see anything that looks suspicious. I don't have time to set this up again in another installation. So if these field names being combined is not being seen on others' systems, I will take that to mean that there is something strange about my setup, and there is nothing wrong with ddblock in this regard. If you agree, please go ahead and update the status accordingly. Thank you for your responses.
Comment #5
ppblaauw commentedMaybe I did not understand your issues or you did not understand my answers. I will try to be more clear.
The field_names are made by CCK and will depend on several things.
If you change one of the above, CCK will change the fieldname and you will also have to change the fieldnames in the preprocess functions of the ddblock module.
With the debug lines in the preprocess functions you can see what fieldnames CCK makes and are available.
In the preprocess functions these fieldnames are used to make variables for the ddblock template files.
You can combine the available fields from CCK/views in the preprocess function to make variables available to the ddblock theme. In the ddblock theme files you can use these variables.
Hope this describes better what the field names are and where they are used for.
Please let me know.
Comment #6
nadavoid commentedYes, that is what I understood. Thank you for the response.
Also, I do have a working solution up right now. I'm able to inspect the variables and pass them on to the template.
My only questions deal with only the name of the variables. It seems that the variable names are longer than they should be. I will try to describe what is happening and why I think it is unexpected.
1. I created some CCK fields, including:
- field_header_display_yn
- field_teaser_text
Both of these are single-value fields. They are currently used only in one content type. It's possible that in the future they might be used in other content types, but they are not yet.
2. I created a view that included those two fields, as well as other fields, such as image.
3. I added the necessary preprocess functions, e.g.
[themename]_preprocess_ddblock_cycle_block_contentto template.php4. On the first line inside that function, I added
dpm($vars['content'][0]);just see what it inside that variable.Based on the fields that I added, I would expect to see field names such as:
node_data_field_header_display_yn_valueor
node_data_field_teaser_text_valueHowever, what I see is
node_data_field_header_display_yn_field_teaser_text_valueThat is the name of a variable that comes in through the $vars variable that is passed to the preprocess function. There is nothing that I did in CCK or Views to combine those two fields into one variable name.
Inside the
foreach ($vars['content'] as $key1 => $result) {loop, I am able to use these variables just fine. What I ended up using was this:$result->node_data_field_header_display_yn_field_image_fidfor the image
and this:
$result->node_data_field_header_display_yn_field_teaser_text_valuefor the teaser text.
It seems that "field_header_display_yn" is unnecessarily in the variable name, since the actual field that is represented is field_teaser_text, and has nothing to do with "field_header_display_yn". And really, that's OK. By using dpm(), etc. I can see the variable name and its values, so I know what to use in the template. So for me, this is really a non-issue now. I just thought is was sort of strange.
Comment #7
ppblaauw commentedOk, I am glad you understand how it works, I thought I was not clear enough.
The issue remains, why CCK makes this fieldnames. (i don't know)
Maybe you can find more information in the CCK documentation or in the CCK issue queue.
Otherwise maybe post this in the CCK issue queue.
Comment #8
nadavoid commentedGood deal. Thanks for the clarifications. I guess this is more of a CCK issue. I'll take it there if I decide to pursue it further.
Comment #9
glennnz commentedHi
I'm trying to figure this out too, and can't get it.
I have a CCK field for the photographer's name of the image I am displaying, and I want to show an, "Image by John Smith" text block floating over the image.
In my template.php preprocess function I have added, immediately under the slide_read_more and slide_node variable:
Then, in my ddblock-cycle-block-content-upright50.tpl.php file, I have added, immediately after
print $slider_item['slide_image'];:Then, in my ddblock-cycle-upright50.css file, I have added:
The field content is not showing up on my block.
URL is http://www.wildrivers.org.nz - see the front page only.
Thank
Glenn
Comment #10
ppblaauw commentedLooked at the site and see:
Looks like it is working correctly. I can also not find an error in your code snippets.
Where do I need to look at?
Comment #11
glennnz commentedSorry, I fixed this and never got back here to update my post.
Glenn
Comment #12
m.zerres commentedcan you tell me how you fixed it?
Markus