An advanced Dynamic display block slideshow uses two preprocess functions to convert view fields into template variables. One for the whole slideshow template and one for the pager template.
Note: Only a custom pager needs a preprocess function for the pager template.
The preprocess functions have to be placed in the template.php file of your theme.
Download and install preprocess functions
Important: Don't copy the <?php from the file to your template.php file.
Important: Several users have an issue with the images not showing up. The slideshow works but the images are not show. In the trouble shooting part of the FAQ you can find the solution for this. The FAQ question is: Images not showing, only grey box.
Note: You can see the view_name and the available view fields by uncommenting the drupal_set_message or dsm debug lines at the top of each preprocess function.
In the example preprocess function the following variables are now available in the slideshow template for each slide.
and the following for each custom-pager-item
Changing view_name and or view_field names
If you use a different view_name and/or view fields than in the advanced slideshow tutorial you have to change them in the preprocess functions.
Uncomment the drupal_set_message lines at the top of the two preprocess function.
[theme_name]_preprocess_ddblock_cycle_block_content and [theme_name]_preprocess_ddblock_cycle_pager_content.
You will now see the result of the drupal_set_message lines, which shows the view_name and the view_fields of your view. You can use this for changing the view_name and the view_field names in the preprocess functions in the template.php file.
Changing view_name
In the line:
if ($vars['settings']['view_name'] == 'news_items') {
if ($vars['settings']['view_name'] == '[VIEW_NAME]') {
Changing view_field_names
In the lines like:
if (isset($result->node_data_field_pager_item_text_field_slide_text_value)) { $slider_items[$key1]['slide_text'] = $result->node_data_field_pager_item_text_field_slide_text_value; }
if (isset($result->[VIEW_FIELD_NAME])) { $slider_items[$key1]['slide_text'] = $result->[VIEW_FIELD_NAME]; }
Note:
After you have changed the view_name and field_names comment the drupal set_message line again.
Comments
Changing view_name and or view_field names
hi..i have added the template.php.txt file in my template.php file..into a seperate PHP tag between the body tag..but i m unable to find out the the view_name and view_field of my views..
what is the process for finding the name of view_field and view_name... .
please describe me in detail..
i am using AD_NOVASE theme.there is no template.php file in this theme..so i put the preprocessor funcation in page.tpl.php
have i done right thing..
Re: Changing view_name and or view_field names
When a theme has no template.php file you need to create a template.php file in the root folder of the theme you use.
In this template.php file you place the preprocess functions.
The view name and fieldnames can be found by uncommenting the drupal_set_message lines in the preprocess functions.
Hope this helps you further, please let me know.
If not please create an issue in the issue_queue of the module.
Re: Changing view_name and or view_field names
hi ..tnx for suggestion..but it is not helpful..
On creating template.php on root folder of theme..i m getting this error..
Parse error: syntax error, unexpected $end in /opt/lampp/htdocs/drupal-6.15/themes/ad_novus/template.php on line 46
what should i do now...
Re: Re: Changing view_name and or view_field names
Thanks for creating an issue in the issue queue of the module, will answer there further.
Re: Re: Changing view_name and or view_field names
i have created the issue..nut didnt fine the soultion.. my problem is very simple.but no one understood that.
i just want to know that after uncommenting drupal_set message what should i do to know the name of view name and view field.
pleas read the issue..
http://drupal.org/node/693812
Preprocess functions cause white screen
Greetings,
When I add the preprocess function to my theme, I end up a white screen.
I did not change the view or file names.
I have removed <?php from the beginning of the code and correctly changed [THEME_NAME] on both functions.
Everything else appears to be working, as without the preprocess functions, the block displays the same preview I see when editing the news_items View.
Re: Preprocess functions cause white screen
Please make an issue in the issue queue of the module and attach your template.php file.
regarding slideshow problem
Hi There,
I am followed the given steps and create a dynamic display block inside a page. Everything the pager, slide text are coming properly but the images are not being displayed.
As I think there is problem with the imagecache settings. Please tell me where are the steps to set preset for images.
Thanx in advance.
Re: regarding slideshow problem
You can find suggestions in the advanced slideshow troubleshooting part of the faq what can be wrong when the image don't show up but the other parts of the slideshow are showing.
If you can not find the answer there please search the issue queue on drupal.org.
If you still can not find the answer, please make a new issue in the issue queue (better monitored) and send your template.php file, the result of the drupal_set_message debug lines when you uncomment them in the top of the preprocess functions. Also a link to the site will help in solving the issue.
warning: Invalid argument supplied for foreach() in W:\www\ddblo
Got error message like this:
warning: Invalid argument supplied for foreach() in W:\www\ddblock\themes\garland\custom\modules\ddblock\ddblock-cycle-block-content-upright40.tpl.php on line 47.
all choise got same error message...
how fix that?thx for atention and helping...
Re: warning: Invalid argument...
Have a look at this faq question
We also just finished the advanced slideshow tutorial. You can see it at: http://www.archive.org/details/Ddblock-AdvancedDynamicDisplayBlockSlides...
The pictures at the site http://gavick.isgreat.org/ look great. Would be nice to see them in the dynamic display block module.
Hope this helps you further. If not see you in the issue queue.
Great module. Doc. suggestion.
Hi, you might want to specify that you have to rename the entire "[THEME_NAME]", including the brackets. So that people don't try this: "[some_theme_name]_preprocess_ddblock_cycle_block_content", when it should be this: "some_theme_name_preprocess_ddblock_cycle_block_content".
Otherwise this is great documentation for a great module.
Re: Great module. Doc. suggestion.
Thanks for the suggestion. Done. We always try to improve the documentation. More suggestions welcome.
Hi i am getting this error
Hi i am getting this error when i copy the Code to my template.php file
Parse error: syntax error, unexpected '[', expecting T_STRING in /home/newinfi/public_html/site/themes/acquia/acquia_marina/template.php on line 661Re: Hi i am getting this error
You need to change [theme_name] to the name of the theme you use.
Don't leave the brackets.
Hope this helps you further, please let me know.
Thanks! Now It's not showing
Thanks!
Now It's not showing any error,
But 'ddblock-News item slideshow' Block is disppearing form the region,
I can only see title called ddblock-News item slideshow.
Problem with zen own subthem (from STARTERKIT)
Hey..
I've read twice and read again.. but anything !
When I uncomment line in template.php there's nothing. More than all, I've got problems to import examples files into CCK and views (don't understand why, so strange : I've just copy and past the content of the two files into the import section of thoses mods, but seems to be wrong ! I thought it was a problem with Imagefield and the new version of Filefield and I took a look into the code... but it seemed to be good again since drupal support.) !
So I tried to create my own fields with views and CCK, and... not any result.
Please, help me, be glad and honored to use your module.
Thanks for your GREAT support !
Re: problem with zen...
Can you first have a look at similar issues in the issue queue (http://drupal.org/project/issues/ddblock) at drupal.org
If you can not find the answer there, please make a support request in the issue queue.
Please make one post per issue, so issues can be managed.
The issue queue is better monitored then the site ddblock.myalbums.biz
Theme other then Garlad?
Thank you for the awesome module.
My ddblock node displays fine in garland theme, but not in a new them I installed. I updated template.php and appended the theme name. The debug info shows fine, but not the ddblock.
Any thoughts?
Thanks!
RE: Theme other then Garland?
Ahh!
I forgot to upload the ddblock custom theme folder to the new theme.
Also, remeber to run update.php when you modify your theme files.
Read more link to somewhere else
When I'm creating a slideshow most of the time I like to be a link to somewhere else, not the slideshow node. So here's what I did. I created a text (not link) field in my content type and added that field to the view.
The field is: field_slideshowlink
The preprocess function now looks like this:
// add slide_read_more variable and slide_node variable if (isset($result->nid)) { $slider_items[$key1]['slide_read_more'] = l('Read more...', $result->node_data_field_slideshowimage_field_slideshowlink_value); $slider_items[$key1]['slide_node'] = 'node/' . $result->nid; }This way the Read more becomes a link to a page, a node, or whatever, but not to the slideshow node.
i used your script but a little different
i used your script but i changed something, and it also working properly
// add slide_read_more variable and slide_node variable
if (isset($result->nid)) {
$slider_items[$key1]['slide_read_more'] = l('Read more...', $result->node_data_field_pager_item_text_field_url_value);
$slider_items[$key1]['slide_node'] = 'node/' . $result->nid;
}
i tested on Amity Island Theme and FF3.5.3+D6.14
Re: Read more link to somewhere else
Thanks for sharing this.
Have a look at the howto page : How to link Read more... button to another page instead of the node. how we described it.
Please keep posting!!!
No template.php file in some themes
Hi,
What about my theme "foliage", it does not have a template.php.
Can you provide an example one for me?
If I just copy all your functions into a new file called template.php, drupal complains about views function not available.
Re: No template.php file in some themes
Should work by creating a template.php file.
What is the error you get?
Have also a look at the FAQ for troubleshooting.
Thanks, I used the garland
Thanks, I used the garland template.php, made your changes, and its accepted that, so onward I go!
a question about this pager...
I appended the the template.php file in the zip file to the bottom of the themese template.php file.
I renamed the two functions in the theme to the theme name.
but the views_export and news_item_cck_export files... I dont think I can just append them to the template php file...could you give me a hint here please. are they suppose to be included in the dir, or added to a file?
Re: a question about this page
The news_item export file is for importing a content type and the views_export file is for importing a view.
Importing the content type and the view are done earlier in this tutorial.
Please read the whole tutorial from start to end if you are not that experienced in Drupal. To get the advanced settings of the dynamic display block module working you need to have basic Drupal knowledge. Setting up the module with this tutorial can also be a help to understand more about the technical backgrounds of Drupal.
You can find information about content types and views in the Drupal handbooks. Just browse the handbooks or find it with a search engine.
Hope this helps you further
Thanks for the module. Im
Thanks for the module.
Im trying to install it but im not having a good time with this part. I download export-files.zip, open tmplate.php, copy it all to my themes template. Then i go to my site and I just get white screen. What should I be doing?
I know its something with the template.php because i didnt have the error before.
Thanks
Re: Thanks for the module
Need some more info to help you:
Did you use the CCK Content-type import?
Did you use the view import?
Did you copy the preprocess functions from the template.php.txt file the template file of your theme?
Did you change [theme-name] To your theme-name?
Did you change view-names, field-names?
Did you uncomment the drupal_set_message lines?
If you did all this can you send me your template.php file.
Fatal error in template.php
Am pasting my template.php also. Rechecked to see if i have done everything you have documented...:-(..Sorry for the trouble: I am getting the following error: Fatal error: Class 'view' not found in /home/ronaldk7/public_html/themes/amity_island/template.php on line 406
Re: fatal error
You only need to add the preprocess functions in the template.php file.
You also added the cck export and the views export into your template.php.
The cck export is for importing a content type. You use it with the CCK functionality.
The views export is for importing a view. You use it with the views functionality.
Hope this heps you further, please let me know.
Thanks for the help ive done
Thanks for the help
ive done everything in the tutorial exactly as shown/stated. I copy the preprocess functions into garlands template and change the theme name to Garland, the when i refresh i get white screen. Everything else ive kept the same because ive done exactly as shown. Ive tried it with Dev and without Dev module.
This is my template
<?php // $Id: template.php,v 1.16 2007/10/11 09:51:29 goba Exp $ /** * Sets the body-tag class attribute. * * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed. */ function phptemplate_body_class($left, $right) { if ($left != '' && $right != '') { $class = 'sidebars'; } else { if ($left != '') { $class = 'sidebar-left'; } if ($right != '') { $class = 'sidebar-right'; } } if (isset($class)) { print ' class="'. $class .'"'; } } /** * Return a themed breadcrumb trail. * * @param $breadcrumb * An array containing the breadcrumb links. * @return a string containing the breadcrumb output. */ function phptemplate_breadcrumb($breadcrumb) { if (!empty($breadcrumb)) { return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>'; } } /** * Allow themable wrapping of all comments. */ function phptemplate_comment_wrapper($content, $node) { if (!$content || $node->type == 'forum') { return '<div id="comments">'. $content .'</div>'; } else { return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>'; } } /** * Override or insert PHPTemplate variables into the templates. */ function phptemplate_preprocess_page(&$vars) { $vars['tabs2'] = menu_secondary_local_tasks(); // Hook into color.module if (module_exists('color')) { _color_page_alter($vars); } } /** * Returns the rendered local tasks. The default implementation renders * them as tabs. Overridden to split the secondary tasks. * * @ingroup themeable */ function phptemplate_menu_local_tasks() { return menu_primary_local_tasks(); } function phptemplate_comment_submitted($comment) { return t('!datetime — !username', array( '!username' => theme('username', $comment), '!datetime' => format_date($comment->timestamp) )); } function phptemplate_node_submitted($node) { return t('!datetime — !username', array( '!username' => theme('username', $node), '!datetime' => format_date($node->created), )); } /** * Generates IE CSS links for LTR and RTL languages. */ function phptemplate_get_ie_styles() { global $language; $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />'; if (defined('LANGUAGE_RTL') && $language->direction == LANGUAGE_RTL) { $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>'; } return $iecss; } /** * Override or insert variables into the ddblock_cycle_block_content templates. * Used to convert variables from view_fields to slider_items template variables * * @param $vars * An array of variables to pass to the theme template. * */ function [Garland]_preprocess_ddblock_cycle_block_content(&$vars) { if ($vars['output_type'] == 'view_fields') { $content = array(); // Add slider_items for the template // drupal_set_message('<pre>' . var_export($vars['settings']['view_name'], true) . '</pre>'); // drupal_set_message('<pre>' . var_export($vars['content'][0], true) . '</pre>'); if ($vars['settings']['view_name'] == 'news_items') { foreach ($vars['content'] as $key1 => $result) { // add slide_image variable if (isset($result->node_data_field_pager_item_text_field_image_fid)) { // get image id $fid = $result->node_data_field_pager_item_text_field_image_fid; // get path to image $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid)); $slider_items[$key1]['slide_image'] = $filepath; } // add slide_text variable if (isset($result->node_data_field_pager_item_text_field_slide_text_value)) { $slider_items[$key1]['slide_text'] = $result->node_data_field_pager_item_text_field_slide_text_value; } // add slide_title variable if (isset($result->node_title)) { $slider_items[$key1]['slide_title'] = $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'] = 'node/' . $result->nid; } } $vars['slider_items'] = $slider_items; } } } /** * Override or insert variables into the ddblock_cycle_pager_content templates. * Used to convert variables from view_fields to pager_items template variables * Only used for custom pager items * * @param $vars * An array of variables to pass to the theme template. * */ function [Garland]_preprocess_ddblock_cycle_pager_content(&$vars) { if (($vars['output_type'] == 'view_fields') && ($vars['pager_settings']['pager'] == 'custom-pager')){ $content = array(); // Add pager_items for the template // drupal_set_message('<pre>' . var_export($vars['pager_settings'], true) . '</pre>'); // drupal_set_message('<pre>' . var_export($vars['content'][0], true) . '</pre>'); if ($vars['pager_settings']['view_name'] == 'news_items') { foreach ($vars['content'] as $key1 => $result) { if (isset($result->node_data_field_pager_item_text_field_image_fid)) { $fid = $result->node_data_field_pager_item_text_field_image_fid; $filepath = db_result(db_query("SELECT filepath FROM {files} WHERE fid = %d", $fid)); $pager_items[$key1]['image'] = $filepath; } if (isset($result->node_data_field_pager_item_text_field_pager_item_text_value)) { $pager_items[$key1]['text'] = $result->node_data_field_pager_item_text_field_pager_item_text_value; } } } $vars['pager_items'] = $pager_items; } } <code>Re: Thanks for the help
You have to get the brackets around garland
I'am sorry if this was not clear.
It should not be:
but
Hope this helps you further, please let me know
re: another suggestion for the blank white screen
also remove this line ddblock template file
since this is already on the template.php and will cause the blank white screen.
You said, "also remove this
You said, "also remove this line ddblock template file".
Can you be more specific which the line you are referring to, please.
Thanks,
Erin
Re: You said also remove this
The code filter applied to the site removed
That is the line to remove when you add the preprocess functions to an existing template.php file.
Thanks re: another suggestion....
Thank you for reporting.
Added a note in the tutorial.
ppblaauw