I need the "Read More" to link to a named anchor within a page, such as www.example.com/page#anchor, but DDBlock is outputting this: www.example.com/page%2523anchor

Any ideas?

Thanks!!

Comments

ppblaauw’s picture

Status: Active » Postponed (maintainer needs more info)

What is the code you use for the read more button in the content preprocess function for the ddblock module in your template.php file. Can you attach your template.php file so I can help you better.

mgladding’s picture

Is this what you are looking for?

From my template.php file:

 // 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);
}
ppblaauw’s picture

Category: bug » support

The l() function in Drupal 6 uses an $options array where you can pass a fragment.

'fragment' - A fragment identifier (named anchor) to append to the link. Do not include the '#' character.

To split the named anchor from your original URL you can use:

explode('#',$result->node_data_field_pager_item_text_field_url_value)

The code, including an if statement to check if the URL has a named anchor part,would become:

// add slide_read_more variable
if (isset($result->node_data_field_pager_item_text_field_url_value)) {
  if (stristr($result->node_data_field_pager_item_text_field_url_value,'#')) {
    $split_url = explode('#',$result->node_data_field_pager_item_text_field_url_value);
    $slider_items[$key1]['slide_read_more'] =  l('Read more...', $split_url[0], array('fragment' => $split_url[1],));
  } 
  else {
    $slider_items[$key1]['slide_read_more'] =  l('Read more...', $result->node_data_field_pager_item_text_field_url_value);
  }
}

Hope this helps you further, please let me know.

Make this a support request and will add this to the preprocess snippets at http://ddblock.myalbums.biz/preprocess_snippets