How to link Read more... button to another page instead of the node

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

Important Notes

  • This tutorial is for of the Dynamic Display Block module version 1.x. Please upgrade to the latest recommended version.
  • Please post only comments with corrections regarding the documentation. We aim to quickly move corrections into the documentation.
  • Before making comments, please search the issue queue. Search on all issues.
  • When you have issues, support request or comments, the preferred place to post them is in the issue queue of the project. The issue queue of the project is monitored daily.
  • Support requests, bug reports, and off-topic comments will be deleted without warning.

Summary

  1. Add URL field to the content type you use for the slideshow
  2. Add URL field to the view you use for the slideshow
  3. Add link to the nodes you use for the slideshow
  4. 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:

  1. Go to Admin > Content types > News item.

Add Url field

  1. Click the Manage field link of the News item content type under Operation.
  2. Fill in the following text field to add new fields for News item content type:
    1. Label - e.g (Url)
    2. Field name - e.g (url)
    3. Type of the data to store - choose from the select box option Text.
    4. Form element to edit the data - choose Textfield from the select box option Textfield.
    5. Click Save button.

Note: When you have the Content Permissions sub-module of CCK enabled, make sure you give permissions for this field.

Configure Url field:

  1. Size of textfield - required, e.g (30 change the default size of the textfield).
  2. Help text textarea - (optional).
  3. Required checkbox - (optional).
  4. Leave the other default settings.
  5. 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:

  1. Go to Admin > Site building > Views >.

Add URL field

  1. Under the list of views, find view: news_items and click the Edit link tab.
  2. Click News item slideshow at the left side of the page under Default tab.
  3. Click + sign button in the Fields fieldset.
  4. Select Content in the select box options Groups and check Content: Url - (field_url).
  5. Click Add button.
  6. Configure field Content: Url - (field_url), select Plain text under Format select box option and leave the other default settings.
  7. Click Update button.
  8. 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.

When you click the "read more" and it does not go to the page but just the next slide is shown, 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?

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

I really do have a doubt in

I really do have a doubt in the crm software previous codes. Is there a need to provide values in the URL field in the node? I also want to know whether we can add a link under the image that I upload.

Is there a Drupal 7

Is there a Drupal 7 alternative or way of achieving the same effect

Искусственный камень много

Искусственный камень много легче природного (обычно в 1 5 раза) с ним несложно работать. При его использовании нет необходимости дополнительно укреплять покрываемые им поверхности. искусственный камень декоративный

Reply to comment | Dynamic display block slideshow module for

I'm no longer sure the place you are getting your information, however great topic.
I needs to spend some time learning more or figuring out more.

Thanks for wonderful info I was in search of this information for my mission.

Reply to comment | Dynamic display block slideshow module for

I am curious to find out what blog system you're working with?
I'm having some small security problems with my latest site and I would like to
find something more secure. Do you have any recommendations?

Re: Is there a Drupal 7 alternative

When i use a registered account,it dosen't go to the page i want

Hello
My DDblcok slideshow works perfectly, when I use admin account. The "read more" button links the right page. But when use the other kinds of accounts such as registered, it just goes to the node which is that slide show. In this situation, it means the value turns to isset($result->nid). I have given account the rights of view and administrater.
Please guide me. Thank you!

I've solved it. It's because

I've solved it. It's because of content_permissions module. Just configure it at Administer > User management > Permissions > content_permissions module.

Is this apply to view slideshow ddblock V2 ?

I am not sure if I need to intall the preprocess functions in V2, but I want to change the read more button to point to another URL. I've created the new field (url) in a new content type for views slide show, but from there I don't know how to link the button to the node (other URL)

Can someone help ?

Thanks

re: Is this apply to view slideshow ddblock V2 ?

Send you an email yesterday. You can have a look at the following link for views_slideshow_ddblock read more to other pages:
http://drupal.org/node/832068

P.S. Please make issues in the issue queue of the module instead of on documentation pages

Sorry, i did'nt see your

Sorry, i did'nt see your email yesterday. I would like to thank you for your help ! it's working now. You have amazing skills and wonderful product. Best regards.

target="_blank"

Awesome module. Just love it. Love the theme I purchased from you, as well.

What is the best way to have Read more... open in a new window? Ideally, a radio button option to choose (i.e. the external links open in a new window).

Thanks!

Re: target="_blank"

From the drupal.api documentation: http://api.drupal.org/api/function/l#comment-282

l(t('Title'),$url, array('attributes' => array('target' => '_blank')));

// 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, array('attributes' => array('target' => '_blank')) );
}

or

l(t('Title'), $url, array('attributes' => array('onclick' => 'window.open(this.href); return false;')));

// 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, array('attributes' => array('onclick' => 'window.open(this.href); return false;')));
}

Hope this helps you further, please let me know.

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

help me

hi and thanks for good support but i have problem whit read more yet i do any things u said in tutorial now when i remove comment of drupal_set_message i see this code and url field valuse is null pls help me thanks alot

array (
'delta' => '1',
'output_type' => 'view_fields',
'pager' => 'custom-pager',
'pager_container' => NULL,
'pager_event' => NULL,
'pager_height' => 63,
'pager_width' => 195,
'imgcache_pager_item' => '',
'pager_position' => 'bottom',
'template' => 'custom',
'custom_template' => 'gradient-green50p',
'view_name' => 'news_items',
)

stdClass::__set_state(array(
'nid' => '35',
'node_title' => 'i think mitida',
'node_data_field_pager_item_text_field_pager_item_text_value' => 'wqw',
'node_type' => 'ddblock_news_item',
'node_vid' => '35',
'node_data_field_pager_item_text_field_slide_text_value' => 'qwqwqw',
'node_data_field_pager_item_text_field_image_fid' => '36',
'node_data_field_pager_item_text_field_image_list' => '1',
'node_data_field_pager_item_text_field_image_data' => 'a:2:{s:3:"alt";s:0:"";s:5:"title";s:0:"";}',
'node_revisions_body' => 'qwqwqw',
'node_revisions_format' => '1',
'node_data_field_pager_item_text_field_url_value' => NULL,
'node_created' => '1284489155',
))

///////////////////////////////////////////////////////////////////////
'news_items'

stdClass::__set_state(array(
'nid' => '35',
'node_title' => 'i think mitida',
'node_data_field_pager_item_text_field_pager_item_text_value' => 'wqw',
'node_type' => 'ddblock_news_item',
'node_vid' => '35',
'node_data_field_pager_item_text_field_slide_text_value' => 'qwqwqw',
'node_data_field_pager_item_text_field_image_fid' => '36',
'node_data_field_pager_item_text_field_image_list' => '1',
'node_data_field_pager_item_text_field_image_data' => 'a:2:{s:3:"alt";s:0:"";s:5:"title";s:0:"";}',
'node_revisions_body' => 'qwqwqw',
'node_revisions_format' => '1',
'node_data_field_pager_item_text_field_url_value' => NULL,
'node_created' => '1284489155',
))

Re: help me

You need to give a value for the URL field in the node.
In the debug lines only the content of the first slide is show, maybe you added URL values in other nodes, but not in the first node shown in the slideshow.

Hope this helps you further.

How to link the image to a link

I have used dd block and it works perfectly. Now i want to make a link for each image of the slide and for the Title field. Is it possible to add a url field under the title and another one under the upload image in the content type?