Hi,
this module is really great! Now I want just to change one little thing:
I want to link to an external page instead linking to the full node.
So I think, I can do it just in modifying the code in the template.php.

There I find the hyperlink to the full node - what do I have to do to link to a cck-field containing a webadress (e.g. field_www with value http://www.linkpage.com).

Kind regards

vistree

Comments

ppblaauw’s picture

Status: Active » Postponed (maintainer needs more info)

Yes, you are right. You have to change the code in the template.php file.

In the content preprocess function you change e.g.

        // add slide_read_more variable
        if (isset($result->nid)) {
          $slider_items[$key1]['slide_read_more'] =  l('Read more...', 'node/' . $result->nid);
        }

to

        // add slide_read_more variable
        if (isset($result->[your_field_name])) {
          $slider_items[$key1]['slide_read_more'] =  l('Read more...', $result->[your_field_name]);
        }

with your example fieldname: field_www

        // add slide_read_more variable
        if (isset($result->field_www)) {
          $slider_items[$key1]['slide_read_more'] =  l('Read more...', $result->field_www);
        }

Just find out what the CCK fieldname really is.
You can do this by uncommenting the debug lines (drupal_set_message or dsm)

Hope this helps you further. Please let me know.

vistree’s picture

Status: Fixed » Postponed (maintainer needs more info)

Oh yes, that it is! Thank you very much!!!

Just had to modify a little thing:
It did not work with the field_www itself, instead I got the "fields name" from the view info:
node_data_field_pager_item_text_field_www_value

So it has the same form as the other fields in your template.php-code

Thank you again

vistree

vistree’s picture

Title: Link to webpage from cck-field instead of "Read more" » Solved: Link to webpage from cck-field instead of "Read more"
Status: Postponed (maintainer needs more info) » Fixed

Status: Postponed (maintainer needs more info) » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

firemountain’s picture

i am having trouble with this issue.

how did you set this up to work. i'm not sure how to get "view info" are you linking to a view or am i just totally looking the wrong way.

if you care to i would really apreciate a pointer,
i am trying to link within the site to a url. i made a cck field and i called it field_www, and i changed the preprocess stuff. how did you do it differnt i'm not quiet sure what you mean here.

thank you

fm

ppblaauw’s picture

If you make a field called field_www in CCK, CCK will make an internal name for it.

Your field_www will become something like node_data_field_pager_item_text_field_www_value

This internal CCK name is what you use.

With uncommenting the drupal_set_message debug lines in the preprocess functions you can see what the names is ("view info")

Now look again at post #1.

Hope this helps you further. Please let me know.

vistree’s picture

Yes, this is exactly how I solved it:
I set up a CCK-text-field (not a link!) "www" (which becomes field_www) as plain text to store the full web-address inside (e.g. http://www.drupal.org)
Then I inserted in my template.php the following code:

function beginning_preprocess_ddblock_cycle_block_content(&$vars) {
  if ($vars['output_type'] == 'view_fields') {
    $content = array();
    // Add slider_items for the template
    // If you use the devel module uncomment the following line to see the theme variables
    // dsm($vars['settings']['view_name']);
    // dsm($vars['content'][0]);
    // If you don't use the devel module uncomment the following line to see the theme variables
    // 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->node_data_field_pager_item_text_field_www_value)) {
          $slider_items[$key1]['slide_read_more'] =  l('to the site', $result->node_data_field_pager_item_text_field_www_value);
        }



      }
      $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 beginning_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
    // If you use the devel module uncomment the following lines to see the theme variables
    // dsm($vars['pager_settings']['view_name']);
    // dsm($vars['content'][0]);
    // If you don't use the devel module uncomment the following lines to see the theme variables
    // 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;
  }
}

which is only minimal manipulated example from the original code. I just changed an filled in the following code (thanks to ppblaauw!)

if (isset($result->node_data_field_pager_item_text_field_www_value)) {
  $slider_items[$key1]['slide_read_more'] =  l('to the site', $result->node_data_field_pager_item_text_field_www_value);
   }

This is enough to link to an external web-site instead of linking to the full node.

Hope this helps.

Nice weekend

vistree

firemountain’s picture

thank so much fro your response and help. I'm still stumped tho. I did already fill in this code goin goff what i read in the earlier posts, nothing else. I have uncommented the drupal_set_message and i have created a CCK field called www (field_www) in it i enter a web address (in my case it is another page within my site but i still write the whole address)

In the info that comes up i don't see any thing showing that it recognizes my field_www?

*

array (
'delta' => '3',
'output_type' => 'view_fields',
'pager' => 'custom-pager',
'pager_container' => NULL,
'pager_event' => NULL,
'pager_height' => 63,
'pager_width' => 195,
'pager_position' => 'top',
'template' => 'upright50',
'custom_template' => NULL,
'view_name' => 'news_items',
)

*

stdClass::__set_state(array(
'nid' => '153',
'node_title' => 'Climate Change in the context of 2012',
'node_data_field_pager_item_text_field_pager_item_text_value' => 'Climate Change ',
'node_data_field_pager_item_text_nid' => '153',
'node_type' => 'ddblock_news_item',
'node_data_field_pager_item_text_field_slide_text_value' => 'Looking at Fluctuating Climate and Natural Disasters, related to 2012 ',
'node_data_field_pager_item_text_field_image_fid' => '443',
'node_data_field_pager_item_text_field_image_list' => '1',
'node_data_field_pager_item_text_field_image_data' => 'a:1:{s:11:"description";s:1:"a";}',
'node_revisions_body' => 'climate change na na na ',
'node_revisions_format' => '3',
'node_created' => '1234755605',
))

*

'news_items'

*

stdClass::__set_state(array(
'nid' => '153',
'node_title' => 'Climate Change in the context of 2012',
'node_data_field_pager_item_text_field_pager_item_text_value' => 'Climate Change ',
'node_data_field_pager_item_text_nid' => '153',
'node_type' => 'ddblock_news_item',
'node_data_field_pager_item_text_field_slide_text_value' => 'Looking at Fluctuating Climate and Natural Disasters, related to 2012 ',
'node_data_field_pager_item_text_field_image_fid' => '443',
'node_data_field_pager_item_text_field_image_list' => '1',
'node_data_field_pager_item_text_field_image_data' => 'a:1:{s:11:"description";s:1:"a";}',
'node_revisions_body' => 'climate change na na na ',
'node_revisions_format' => '3',
'node_created' => '1234755605',
))

What happens is the read more button disapears nothing else.
you have already been so kind but please
can you help more ... what do you guys think is going on here?

ppblaauw’s picture

The content comes from the view. The views needs to contains the fields from the content type.
You need to add the field to the view.

Hope this helps you further.

firemountain’s picture

GREAT.

ppblaauw you are so good, check out how the blocks are looking. www.citizen-2012.com

firemountain’s picture