Using an override theme_addthis_button function & button displaying at bottom of node. Understand that I can move $links in node.tpl.php, but can I only access the addthis button which is included in $links?

Comments

cattalk’s picture

Hi,
If you use "Drupal for Firebug" you can easily see the contents of the $node array. Once you have the variable containing the value of your button you can insert the button like this:

<?php print $node->content['links']['add_this_buton']['#value'] ?>

Note: I'm only guessing how the vars are named. You'll have to check for yourself.

Regards
cat

SDM-MINK’s picture

Thxs! I just started using Firebug but not Drupal for Firebug Module. I can see that the button is defined in a class="addthis last" which is contained in class="links". Thus, would I insert the button using this:

print $node->content['links']['addthis_last']['#value']

If not, is there another way to get the variable name without adding the "Drupal for Firebug" Module?

Once I have the variable name,

(1) will I place it after when I place this code after if ($page == 0): and before

or after
and before if ($page == 0): ?

(2) Do I need to place it in a div class?

(3) Will it automatically not display at the bottom of the node with the other $links or do I have to put in add'l coding near print $links; ?

cattalk’s picture

There are several ways to get the variable names, you could use the devel module for example or use

print "<pre>";
print_r($node);
print "</pre>";

also works with

    print_r($block);
    print_r($globals);
    print_r($view);
    print_r($variables); 

when using devel

dsm(get_defined_vars());

place your code in your node template.

use <?php if ($page == 0): ?>

to theme the teaser of your node

and after <?php else: ?>

theme the details

and don't forget the

<?php endif; ?>

So your template could look like this (note that I use custom fields I created using CCK):

Teaser:


<div id="node-<?php print $node->nid; ?>" class="views-row node<?php if ($sticky) { print ' sticky'; } ?><?php if (!$status) { print ' node-unpublished'; } ?>">

	<?php if ($page == 0): ?>
	
	<div class="views-field-created"><div class="pupdate"><?php print $pubdate ?></div></div>
             <h2><a href="<?php print $node_url ?>" title="<?php print $node->title ?>" class="teaser_link"><?php print $node->title ?></a></h2>
	<div class="artikel_teaser">
	<div class="teaser_teaserpic"><?php print $picbox_teaser[0] ?></div>
	<?php print $node->field_teasertext[0]['value']; ?>
	</div>
	<?php if ($taxonomy): ?>
            <div class="terms"><?php print $terms ?></div>
        <?php endif;?>

The detailed view of the node:


<?php else: ?>

<div class="views-field-created"><div class="pupdate"><?php print $pubdate ?></div></div>
<h2><?php print $node->title ?></h2>
<div class="content clear-block">
	<div class="field-field-newscontent">
                  <span class="pretext"><?php print $node->field_pretext[0]['value']; ?></span>
                  <span class="textcontent"><?php print $node->content['body']['#value'] ?></span>
	
	            <?php if($node->field_conclusion[0]['value'] != "") { ?> 
	                 <span class="conclusion"><?php print $node->field_conclusion[0]['safe']; ?></span>
	           <?php } ?>
	
	</div>
  </div>


	
<div class="clear-block">
    <div class="meta">
    <?php if ($taxonomy): ?>
      <div class="terms"><?php print $terms ?></div>
    <?php endif;?>
    </div>

	

    <?php if ($links): ?>
      <div class="links"><?php print $links; ?></div>
    <?php endif; ?>
  </div>

<?php endif; ?>
</div>

Just a rough outline, hopefully I didn't put errors in this example ;)

If your variable is part of the $node->links then it will display if you use

<?php
print $links;
?>

If you don't want certain things to appear from the link variable you have to call the elements you want to display with out using $node->links.

Hope that helps

cat