Notes:
- This "How to" tutorial assumes you have the advanced dynamic display block slideshow working, but you want to link the "Read more..." button to another page instead of the node.
- Links refer to the existing tutorial on this site
Summary
- Add URL field to the content type you use for the slideshow
- Add URL field to the view you use for the slideshow
- Add link to the nodes you use for the slideshow
- Change preprocess function
possible URL's
The value in the URL field could be a relative URL from the page you are on, relative from Drupal root or an absolute URL.
- e.g. node/1, relative to the home page
- e.g /node/1, relative from drupal root
- e.g. http://example.com, absolute URL
Detailed instructions
Add URL field to content type
Path to add new field to the Content type News item:
- Go to Admin > Content types > News item.
Add Url field
- Click the Manage field link of the News item content type under Operation.
- Fill in the following text field to add new fields for News item content type:
- Label - e.g (Url)
- Field name - e.g (url)
- Type of the data to store - choose from the select box option Text.
- Form element to edit the data - choose Textfield from the select box option Textfield.
- Click Save button.
Configure Url field:
- Size of textfield - required, e.g (30 change the default size of the textfield).
- Help text textarea - (optional).
- Required checkbox - (optional).
- Leave the other default settings.
- Click Save field settings button.
Arrange CCK fields
Drag an drop the new URL field after the Pager item text field.
Add URL field to views
Path to add views field:
- Go to Admin > Site building > Views >.
Add URL field
- Under the list of views, find view: news_items and click the Edit link tab.
- Click News item slideshow at the left side of the page under Default tab.
- Click + sign button in the Fields fieldset.
- Select Content in the select box options Groups and check Content: Url - (field_url).
- Click Add button.
- Configure field Content: Url - (field_url), select Plain text under Format select box option and leave the other default settings.
- Click Update button.
- Click Save button.
Arrange View fields
Drag Content: Url - (field_url) Plain text and drop after the Pager item text field.
Add links in the URL field of the nodes you already made
You can now add a link in the Url textfield where the read more.. button has to link to. E.g (http://themes.myalbums.biz).
Change preprocess function
To make the Read more... button link to another page you need to change the code of the [theme_name]_preprocess_ddblock_cycle_block_content preprocess function in your template.php file.
Changes
// 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);
}
Change to:
// add slide_read_more variable and slide_node variable
if (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);
}
or change to the following if not all links have to link to other pages.
// add slide_read_more variable and slide_node variable
if (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);
}
elseif (isset($result->nid)) {
$slider_items[$key1]['slide_read_more'] = l('Read more...', 'node/' . $result->nid);
}
When you want e.g. use a named anchor in the link have a look at: Use named anchor in link of read more button in the Precprocess snippets section.
Using other field names
If you use another field name instead of Url, uncomment the drupal_set_message debug 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
For more information on how to change the template.php file, see Preprocess functions.
Note: After you have changed the view_name and field_names comment the drupal set_message line again.
Comments
Thanks
Hi
This is amazing module and you people made it perfect by giving nice documentation.
Thanks
Different code....
Hello,
The code in 'add slide_read_more variable and slide_node variable' is something different in imported template.php file.
Here it is
// 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;
}
Where as on this page you have given it like this:
// 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);
}
Don't know whether this makes any difference or not, just want to get your attention to this small error.
Re: Different code
The code
$slider_items[$key1]['slide_node'] = base_path() . 'node/' . $result->nid;
is not used in the template so deleted it here.
Thanks for reporting
Thanks for the tutorial, it
Thanks for the tutorial, it works great, this module is truly an amazing piece of work and I am grateful for all the work you have put into this. The documentation you have here is great as well. Thanks.
Read more..button does not link to node
Hi ! all
i have DDblcok slideshow working perfectly but the "read more..." buttom does not link to Node. How can i link "read more.." button to node ?
please kindly guide me.
Regards
januta
Re: Read more..button does not link to node
Have a look at the FAQ question: When I click on the read more button it doesn't go to the node itself but it just goes to the next slide. Why?