How to link slide to a custom node?
Anandyrh - June 3, 2009 - 07:38
| Project: | Dynamic display block |
| Version: | 6.x-1.0-rc6 |
| Component: | User interface |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
| Issue tags: | Advanced slideshow, preprocess functions |
Description
Hi,
I am using Advanced DDBlock slide show, There are 5 slides in my slideshow, I have to link each slide to a custom node.
is this possible?
Regards,
AnAnD

#1
Yes, this is possible.
You can read how in the: How to link Read more... button to another page instead of the node
Hope this helps you further, please let me know.
Please don't assign issues to yourself if you don't solve the issue.
If you assign an issue to yourself, it means YOU will solve the issue, nobody has to do something.
I don't think this is what you mean.
#2
Thanks, But i wanted to link the whole slide to a node?
#3
I do that by disabling the Read more link in the file ddblock-cycle-block-content-upright(Nr.).tpl.php
The Code Before:
</div> <!-- slide-title-inner-->
</div> <!-- slide-title-->
<div class="slide-body-<?php print $slide_direction ?> clear-block border">
<div class="slide-body-inner clear-block border">
<p><?php print $slider_item['slide_text'] ?></p>
</div> <!-- slide-body-inner-->
</div> <!-- slide-body-->
--> <div class="slide-read-more slide-read-more-<?php print $slide_direction ?> clear-block border">
--> <p><?php print $slider_item['slide_read_more'] ?></p>
--> </div><!-- slide-read-more-->
</div> <!-- slide-text-inner-->
</div> <!-- slide-text-->
</div> <!-- slide-inner-->
</div> <!-- slide-->
The code After:
</div> <!-- slide-title-inner-->
</div> <!-- slide-title-->
<div class="slide-body-<?php print $slide_direction ?> clear-block border">
<div class="slide-body-inner clear-block border">
<p><?php print $slider_item['slide_text'] ?></p>
</div> <!-- slide-body-inner-->
</div> <!-- slide-body-->
<-- I removed the Read More linke from here and i linked the node from the Slide Text when i create a new Slide -->
</div> <!-- slide-text-inner-->
</div> <!-- slide-text-->
</div> <!-- slide-inner-->
</div> <!-- slide-->
-------------------------------- So i hope this will help you ----------------------------
Note. if you are using NEXT Option in the DDBLOCK Settings, this read more link will not work Correctly.
#4
The steps are almost the same, only the changes in the preprocess functions are different.
You have to make a link for the image part.
Add the link function l() to the image part.
EDIT, SEE #6 (THIS CODE IS WRONG)
change
$vars['slider_item']['slide_image'] =theme('imagecache',
$vars['settings']['ddblock_imgcache_slide'],
$filepath,
$result->node_title);
to
$vars['slider_item']['slide_image'] =l(theme('imagecache',
$vars['settings']['ddblock_imgcache_slide'],
$filepath,
$result->node_title),$result->node_data_field_pager_item_text_field_url_value);
and
$vars['slider_item']['slide_image'] ='<img src="' . base_path() . $filepath .
'" alt="' . $result->node_title .
'"/>';
to this
$vars['slider_item']['slide_image'] =l('<img src="' . base_path() . $filepath .
'" alt="' . $result->node_title .
'"/>',$result->node_data_field_pager_item_text_field_url_value);
Hope this helps you further, please let me know.
#5
I dont't see these functions in my Preprocess function.
#6
Sorry, I used code from a new theme file
EDIT, SEE #10 (THIS CODE IS WRONG)
You should change:
$slider_items[$key1]['slide_image'] =theme('imagecache',
$vars['imgcache_slide'],
$filepath,
$result->node_title);
}
else {
$slider_items[$key1]['slide_image'] =
'<img src="' . base_path() . $filepath .
'" alt="' . $result->node_title .
'"/>';
}
to
$slider_items[$key1]['slide_image'] =l(theme('imagecache',
$vars['imgcache_slide'],
$filepath,
$result->node_title), $result->node_data_field_pager_item_text_field_url_value );
}
else {
$slider_items[$key1]['slide_image'] =
l('<img src="' . base_path() . $filepath .
'" alt="' . $result->node_title .
'"/>', $result->node_data_field_pager_item_text_field_url_value);
}
#7
NO........!
1) i added text filed to node type
2) added the url to the slide node
3) called the url text field in news item view
4) changed the above given code in template.php file
After doing all this the result was:
1) I could not see backgroung image for the slide show (in all five slides)
2) I can see image source in place of image
Eg:
<img src="/siteroot/sites/default/files/test.jpg" alt="Test Image"/>Please help me out to fix this issue...
Regards,
AnAnD
#8
Hi, ppblaauw
Please help me out...
Thanks & Regards,
AnAnD
#9
Hi faraj,
Thanks i have all ready removed the read more button form the code...
I am on a process to link slide to an custom node... Instead of Read more...Button.
Regards,
AnAnD
#10
Ok, I tested the link on my site, and notice I made a mistake.
The l() function uses the plain_text() function to convert the linktext to plain text.
This means that html characters like < are converted to < and you will not see the image anymore but only the html code.
You need to change the code to
$slider_items[$key1]['slide_image'] ='<a href="' . check_url($result->node_data_field_pager_item_text_field_url_value) . '">' .theme('imagecache',
$vars['imgcache_slide'],
$filepath,
$result->node_title). '</a>';
}
else {
$slider_items[$key1]['slide_image'] =
'<a href="' . check_url($result->node_data_field_pager_item_text_field_url_value) . '"><img src="' . base_path() . $filepath .
'" alt="' . $result->node_title .
'"/></a>';
}
Hope this helps you further, please let me know.
#11
:-)
Hi ppblaauw,
I too got to know the error when i saw the sorce of the slide show and the i managed to do the same like you have done the 'l' function was creating the problem.
But new problem has occored, Now click is working only on the image... If i click on the Title or Slide text the link is not working... So now how do i make whole slide as clickable?
#12
For now i have linked the node_title and slide_text the same way how i linked the background image and have set display:block; in the css file for the styles, It works fine with IE the whole slide is clickable i was happy about it...
But when i checked the same in FireFox just the background image, title and slide text is linked, the whole slide is not clickable, i think diplay:block is not working in firefox.
Thanks & Regards,
AnAnD
#13
Can you send a link to the Internet Site?
Can you attach your template.php file
There is a similar issue asking to link the title and image to the node (see Make the title and image link to the node.
#14
Hi, i managed to link the whole slide now, It works fine with IE6, IE7, IE8 and FireFox.
sure i'll replay to this with link when i go live with my site...
1) Add url field to your content type:
see this link: http://ddblock.myalbums.biz/node/851
2) This the code i have used in template.php to link my background image:
$slider_items[$key1]['slide_image'] =theme('imagecache',
$vars['imgcache_slide'],
$filepath,
$result->node_title);
}
else {
$slider_items[$key1]['slide_image'] =
'<a href="'.$result->node_data_field_slide_text_field_url_value.'">'.'<img src="' . base_path() . $filepath .
'" alt="' . $result->node_title .
'"/></a>';
}
3) Replace the below code in you template.php to link the node_title part.
// add slide_title variableif (isset($result->node_title)) {
$slider_items[$key1]['slide_title'] = $result->node_title;
}
<< To >>
// add slide_title variableif (isset($result->node_title)) {
$slider_items[$key1]['slide_title'] = '<a href="'.$result-
>node_data_field_slide_text_field_url_value.'">'.$result->node_title.'</a>';
}
4) And you have to add
display:blockin to yourdiv.ddblock-cycle-upright30 div.slide-titleStyle in ddblock-css-template.css fileThis should do the job for you...
Regards,
AnAnD
#15
Great it works now for you and thanks for the writeup!
Some remarks about your solution:
2)
If you would use image cache for the slide image there would be no link.
See the code in #10
2,3)
If you would allow others to add URLs it's prefered to use the check_url function to avoid misuse.
See the code in #10
If you allow other to add nodes you could also use check_plain() function for the $result->node_title to avoid misuse.
check_plain($result->node_title)
I set the issue to fixed
Added tags
#16
Thanks, ppblaauw
:-) Job is done for this module.
Regards,
AnAnD
#17
Automatically closed -- issue fixed for 2 weeks with no activity.
#18
hi,
i have some problems having this to work.
i followed eactly what is instructed here
my image is linking but not to my custom node. it is always linking to
<front>.i guess the problem is here: node_data_field_slide_text_field_url_value
is it possible it have changed since older releases?
i tried also:
node_data_field_url_field_url_value
node_data_field_pager_item_text_field_url_value
any thoughts?
thanks
#19
#18
Can you attach your template.php file and the result of the drupal_set_message lines when you uncomment them in both preprocess functions for the ddblock module in the template.php file of your theme.
A link to your Internet site would also be helpful
#20
wow! thanks for the VERY fast answer.
here we go:
'news_items'
stdClass::__set_state(array(
'nid' => '15',
'node_title' => 'Localisation',
'node_data_field_pager_item_text_field_pager_item_text_value' => 'Pager item text',
'node_type' => 'ddblock_news_item',
'node_vid' => '15',
'node_data_field_pager_item_text_field_slide_text_value' => '
Slide test 1
',
'node_data_field_pager_item_text_field_image_fid' => '22',
'node_data_field_pager_item_text_field_image_list' => '1',
'node_data_field_pager_item_text_field_image_data' => 'a:3:{s:11:"description";s:0:"";s:3:"alt";s:0:"";s:5:"title";s:0:"";}',
'node_revisions_body' => '
body
',
'node_revisions_format' => '1',
'node_created' => '1256091090',
))
website: http://www.physiotek.com/node/19
N.B. just realised the link is not
<front>but the actual page. sorry for that mistake. i was testing the module from<front>...thanks again for your help.
#21
Thanks for sending the additional information.
I don't see a field in the debug lines which can be used as a URL.
Did you add an additional URL field to your content type?
Did you add an additional URL field to the views block you use?
Did you give permissions for the field when you use additional permissions modules?
#22
So....
Did you add an additional URL field to your content type? YES
Did you add an additional URL field to the views block you use? YES
Did you give permissions for the field when you use additional permissions modules? I don'T have additional permissions modules
I don't see a field in the debug lines which can be used as a URL. I know. That's why i said that the node_data_field_slide_text_field_url_value command might be in trouble.
BTW i did a mistake when originaly entered the additional URL field in the content type. I wrote ULR instead of URL but i immediatly deleted it and recreated the field with the right typo. Dunno if that might be the cause of the troubles. I guess not. I looked at the database and couldnt see anything wrong. And for extra precautions, i did flush my cache.
Any thoughts?
#23
Do you see the URL field in the views SQL statement in the preview for the block in the news_items view?
Can you attach the sql statement?
#24
I see at your Internet site that the debug lines now contain the field:
node_data_field_pager_item_text_field_url_valueSo the code to add the readmore button would become:
// add slide_read_more variable and slide_node variableif (isset($result->node_data_field_pager_item_text_field_url_value)) {
$slider_items[$key1]['slide_read_more'] = l('Read more...', $result->node_data_field_pager_item_text_field_url_value);
}
You could add an else statement if not all slides have a URL value
What did you do to make the field appear now? Maybe useful for other users.
#25
hi ppblaauw,
everything is working now.
i simply did one mistake when following the steps... and a stupid one... forgot to save my view... argh!
anyway here'S my template.php code finally:
else {if (isset($result->node_data_field_pager_item_text_field_url_value)) {
$slider_items[$key1]['slide_image'] =
'<a href="'.$result->node_data_field_pager_item_text_field_url_value.'">'.'<img src="' . base_path() . $filepath .
'" alt="' . check_plain($result->node_title) .
'"/></a>';
}
else {
$slider_items[$key1]['slide_image'] =
'<img src="' . base_path() . $filepath .
'" alt="' . check_plain($result->node_title) .
'"/>';
}
}
for the slide link if there is a link. otherwise no
<a>// add slide_read_more variable and slide_node variableif (isset($result->node_data_field_pager_item_text_field_url_value)) {
$slider_items[$key1]['slide_read_more'] = l('Read more...', $result->node_data_field_pager_item_text_field_url_value);
}
for the read more link if there is a link. otherwise, no read more button
thanks again for your work and your help!
#26
Thanks for the explaining post
set status to fixed
#27
Automatically closed -- issue fixed for 2 weeks with no activity.