We worked this a little differently as we wanted to share the product image and the product information versus using "like."
Using the basic format for a facebook share WITHOUT a counter
PHP Code:
<a name="fb_share" type="button" share_url="http://www.YOURSITE.com" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
We modified it to use zen_href and include the variables FILENAME_PRODUCT_INFO and zen_get_all_get_params() to result in
PHP Code:
<a href="http://www.facebook.com/sharer.php" share_url="<?php echo zen_href_link(FILENAME_PRODUCT_INFO, zen_get_all_get_params()); ?>" type="button" name="fb_share">Share on Facebook</a><script type="text/javascript" src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"></script>
We enclosed the code in a div with an id of autoFacebookShare and added that to the stylesheet in order to use css to control positioning.
Purists should note that this code will throw a tidy warning for the share_url call.
********************************
Further information that may or may not be helpful as it refers specifically to the basic sophyblue layout (mandi-raesDOTcom is example).
We wanted to put the three links across the bottom of a product's page so, we took a pretty basic SophyBlue template and added a wrapper for all the buttons (review, tell a friend, and facebook share) that we called tellAllWrapper , included a div around the review button called reviewButton, a div around the tell a friend called tellFriend, and the div for the facebook button.
In any three-column display, you need to align and enter data in Left, Right, Middle format in both the tpl file and the stylesheet.css.
So... We modified the tpl_product_info_display.php from
PHP Code:
<!--bof Tell a Friend button -->
<?php
if ($flag_show_product_info_tell_a_friend == 1) { ?>
<div id="productTellFriendLink" class="buttonRow forward"><?php echo ($flag_show_product_info_tell_a_friend == 1 ? '<a href="' . zen_href_link(FILENAME_TELL_A_FRIEND, 'products_id=' . $_GET['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_TELLAFRIEND, BUTTON_TELLAFRIEND_ALT) . '</a>' : ''); ?></div>
<?php
}
?>
<!--eof Tell a Friend button -->
<!--bof Reviews button and count-->
<?php
if ($flag_show_product_info_reviews == 1) {
// if more than 0 reviews, then show reviews button; otherwise, show the "write review" button
if ($reviews->fields['count'] > 0 ) { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params()) . '">' . zen_image_button(BUTTON_IMAGE_REVIEWS, BUTTON_REVIEWS_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
<p class="reviewCount"><?php echo ($flag_show_product_info_reviews_count == 1 ? TEXT_CURRENT_REVIEWS . ' ' . $reviews->fields['count'] : ''); ?></p>
<?php } else { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) . '">' . zen_image_button(BUTTON_IMAGE_WRITE_REVIEW, BUTTON_WRITE_REVIEW_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
<?php
}
}
?>
<!--eof Reviews button and count -->
To
PHP Code:
<!-- bof share buttons by JEANDRET -->
<div id="tellAllWrapper">
<!--bof Reviews button and count-->
<div id="reviewButton">
<?php
if ($flag_show_product_info_reviews == 1) {
// if more than 0 reviews, then show reviews button; otherwise, show the "write review" button
if ($reviews->fields['count'] > 0 ) { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS, zen_get_all_get_params()) . '">' . zen_image_button(BUTTON_IMAGE_REVIEWS, BUTTON_REVIEWS_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
<p class="reviewCount"><?php echo ($flag_show_product_info_reviews_count == 1 ? TEXT_CURRENT_REVIEWS . ' ' . $reviews->fields['count'] : ''); ?></p>
<?php } else { ?>
<div id="productReviewLink" class="buttonRow back"><?php echo '<a href="' . zen_href_link(FILENAME_PRODUCT_REVIEWS_WRITE, zen_get_all_get_params(array())) . '">' . zen_image_button(BUTTON_IMAGE_WRITE_REVIEW, BUTTON_WRITE_REVIEW_ALT) . '</a>'; ?></div>
<br class="clearBoth" />
<?php
}
}
?>
</div>
<!--eof Reviews button and count -->
<!--bof Tell a Friend button -->
<div id="tellFriend"><?php
if ($flag_show_product_info_tell_a_friend == 1) { ?>
<div id="productTellFriendLink" class="buttonRow forward"><?php echo ($flag_show_product_info_tell_a_friend == 1 ? '<a href="' . zen_href_link(FILENAME_TELL_A_FRIEND, 'products_id=' . $_GET['products_id']) . '">' . zen_image_button(BUTTON_IMAGE_TELLAFRIEND, BUTTON_TELLAFRIEND_ALT) . '</a>' : ''); ?></div>
<?php
}
?>
</div>
<!--eof Tell a Friend button -->
<!-- bof Facebook Auto Share by JEANDRET -->
<div id="autoFacebook">
<a href="http://www.facebook.com/sharer.php" share_url="<?php echo zen_href_link(FILENAME_PRODUCT_INFO, zen_get_all_get_params()); ?>" type="button" name="fb_share">Share on Facebook</a><script type="text/javascript" src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"></script>
</div>
<!-- eof Facebook Auto Share by JEANDRET -->
</div>
<!-- eof share buttons by JEANDRET -->
Using the newly created divs and wrappers, we added the following to the end of our stylesheet.css
PHP Code:
/* styles for share buttons by JEANDRET */
#tellAllWrapper {
clear: both;
height: 30px;
padding: 1em;
}
#reviewButton {
float: left;
width: 30%
}
#tellFriend {
float: right;
width: 30%;
}
#autoFacebook {
margin-top: 7px;
text-align: center;
}
We noticed that this link allows facebook to extract all data concerning the product. It attempts to display it all and (so far) we have not been able to determine what information facebook uses. It is not a function of zen cart as the link generated is the simple link to the product page. It is some part of the facebook script that is pulling in a little more info than we would like.
However, we're willing to live with it for now as it is a facebook matter.
Bookmarks