{Hướng dẫn} Chia sẽ mạng xã hội không cần javascript

Thảo luận trong 'Hướng dẫn - Hỏi đáp' bắt đầu bởi kuteboy_195, 25/10/15.

  1. kuteboy_195

    kuteboy_195 Rất tích cực

    Bài viết:
    108
    Likes :
    17
    Chào các bạn, lâu lắm rồi mới quay trở lại diễn đàn , chúc các member luôn khỏe mạnh
    Hôm nay tiện làm web joomla nên chia sẽ các bạn cách tạo chia sẽ mạng xã hội , rất đơn giản mà ko cần javascript , nhiều bạn dùng addthis (rất tốt nhưng mất thời gian load về --- web lại chậm) nên mình chia sẽ cách này các bạn thấy nếu thích thì cho 1 thanks nhé *excited**excited*

    Đây là demo của mình :

    [​IMG]
    Bắt tay vào làm :

    Các bạn vào components/com_content/views/article/tmpl
    Thêm vào dòng này : để phía sau defined('_JEXEC') or die;
    $uri = JFactory::getURI();
    $absolute_url = $uri->toString();
    $doc = JFactory::getDocument();
    $page_title = $doc->getTitle();

    /* cái này dùng để lấy title và url của link mà bạn đang xem trên trình duyệt nhé*/

    Sau đó xuống dưới đoạn có :
    <?php echo $this->item->event->afterDisplayContent; ?>

    Các bạn thêm phía dưới

    <div class="share">
    <strong style="float:left; padding-right:10px;">Chia sẻ mạng xã hội: </strong>
    <a href="http://www.facebook.com/share.php?u=<?php echo $absolute_url; ?>" title="Facebook!" target="_blank" rel="nofollow">
    <img border="0" src="<?php echo $this->baseurl ?>/images/support/facebook.png" alt="Facebook Share">
    </a>
    <a href="https://plus.google.com/share?url=<?php echo $absolute_url; ?>" title="Google Plus Share!" target="_blank" rel="nofollow">
    <img border="0" src="<?php echo $this->baseurl ?>/images/support/google_plus.png" alt="Google bookmark">
    </a>
    <a href="http://twitter.com/home/?status=<?php echo $page_title; ?>+<?php echo $absolute_url; ?>" title="Twitter this!" target="_blank" rel="nofollow">
    <img border="0" src="<?php echo $this->baseurl ?>/images/support/twitter.png" alt="twitter share">
    </a>
    <a href="http://del.icio.us/post?url=<?php echo $absolute_url; ?>" title="Delicious" target="_blank" rel="nofollow">
    <img border="0" src="<?php echo $this->baseurl ?>/images/support/delicious.png" alt="Delicious Share">
    </a>
    <a href="http://digg.com/submit?url=<?php echo $absolute_url; ?>" title="Digg it!" target="_blank" rel="nofollow">
    <img border="0" src="<?php echo $this->baseurl ?>/images/support/digg.png" alt="Digg Share">
    </a>
    <a href="http://pinterest.com/pin/create/button/?url==<?php echo $absolute_url; ?>" title="Printerest it!" target="_blank" rel="nofollow">
    <img border="0" src="<?php echo $this->baseurl ?>/images/support/pinterest.png" alt="Printerest Share">
    </a>
    </div>

    Bạn cần chuẩn bị các icon như facebook , twitter...,sau đó phải style qua css để nó nhìn đẹp mắt hơn
    Viêc còn lại là bạn lưu và vào xem trên bài viết của mình , làm cách này sẽ lấy đúng url cần share
    Nếu bạn nào có cách nào làm hay hơn thì chia sẽ cho mọi người nhé.
     
  2. linhtetohihi

    linhtetohihi Mới tham gia

    Bài viết:
    6
    Likes :
    0
    Nhìn này không biết gì chắc khó hiểu nhỉ, cảm ơn bạn nhiều nha
     
  3. kuteboy_195

    kuteboy_195 Rất tích cực

    Bài viết:
    108
    Likes :
    17
    cứ làm đi là hiểu hết bác ơi , demo web của e bác tham khảo qua : http://mangpevn.com
     
comments powered by Disqus

Chia sẻ trang này