I'm trying to create multiple ddblock slideshows on my site using different views.
I tried to follow the instructions on the faq...
--------------------
# Adjust both preprocess functions in the template.php file
1. Replicate the if statement of the first view (probably the news-items view)
2. Rename news_items to your view name
3. Uncomment the drupal_set_message lines
4. Place ddblock instance on a page/region
5. The result of the drupal_set_message lines tell you what fieldnames CCK has generated
6. Adjust the field_names
7. Reload the page
8. Comment the drupal_set_message debug lines again
-------------------
I attempted to replicate the if statements in the preprocess function, but I'm not sure which part of it to replicate and where it needs to go.
Do I just replicate this?: if ($vars['settings']['view_name'] == 'ddblock_frontpage')
Or do I need replicate more...
-------------------
if ($vars['settings']['view_name'] == 'ddblock_frontpage') {
if (!empty($vars['content'])) {
foreach ($vars['content'] as $key1 => $result) {
// add slide_image variable
if (isset($result->node_data_field_main_image_field_main_image_fid)) {
// get image id
$fid = $result->node_data_field_main_image_field_main_image_fid;
// get path to image
$filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid));
// use imagecache (imagecache, preset_name, file_path, alt, title, array of attributes)
if (module_exists('imagecache') && is_array(imagecache_presets()) && $vars['imgcache_slide'] <> ''){
$slider_items[$key1]['slide_image'] =
theme('imagecache',
$vars['imgcache_slide'],
$filepath,
check_plain($result->node_title));
}
else {
$slider_items[$key1]['slide_image'] =
'
'" alt="' . check_plain($result->node_title) .
'"/>';
}
}
// add slide_text variable
if (isset($result->node_data_field_teaser_field_teaser_value)) {
$slider_items[$key1]['slide_text'] = check_markup($result->node_data_field_teaser_field_teaser_value);
}
// add slide_title variable
if (isset($result->node_title)) {
$slider_items[$key1]['slide_title'] = check_plain($result->node_title);
}
// add slide_read_more variable and slide_node variable
if (isset($result->nid)) {
$slider_items[$key1]['slide_read_more'] = l('Read more...', 'node/' . $result->nid);
$slider_items[$key1]['slide_node'] = base_path() . 'node/' . $result->nid;
}
}
}
}
-------------------
In either case, after I replicate it, where do I to put it.
Thank you very much.
-Joe
Comments
Comment #1
ppblaauw commentedYou need to replicate the whole if statement like in your second example and then place it under the first if statement.
if ($vars['settings']['view_name'] == 'first view name') {
if (!empty($vars['content'])) {
foreach ($vars['content'] as $key1 => $result) {
...
...
}
}
}
if ($vars['settings']['view_name'] == 'second view name') {
if (!empty($vars['content'])) {
foreach ($vars['content'] as $key1 => $result) {
...
...
}
}
}
Same for pager preprocess function
Hope this helps you further, please let me now
Comment #2
pkcho commentedOk, thank you for clarifying so quickly!
I tried that and when I created the instance, and attempted to select the new view, it did not show up in the pull-down menu. It only showed me the original view.
Do I need to create the instance before making the change to the preprocess function, as in your faq?
1) Enable the view for the dynamic display block module.
2) Create a ddblock instance for the view
3) Configure the ddblock instance
4) Adjust both preprocess functions in the template.php file
Comment #3
ppblaauw commentedYou need to enable the new view for the ddblock module in the settings tab before you can use it.
Order of doing this things does not matter.
Comment #4
pkcho commentedYes, I forgot to assign the view in the settings tab, after doing that it worked! Thank you very much for your help!
Is there a limit to the number of views I can use?
Comment #5
ppblaauw commentedGreat it works now!!!
No, there is no limit in the amount of views with different content.
When using a new view just replicate the if statements again.
Always curious to results, do you have a link to your Internet site?