How can I generate ID's so that I can just PHP Include a Facebook App on all pages?

Discussion in 'PHP' started by Airwalk Enterprise, Inc, May 1, 2010.

  1. #1
    I have this comment system:

    <div class="comment">
    <fb:comments xid="THISISTHEID" numposts="10" width="734"></fb:comments>
    <div id="fb-root"></div>
    <script>
    window.fbAsyncInit = function() {
    FB.init({appId: 'THISISTHEID', status: true, cookie: true,
    xfbml: true});
    };
    (function() {
    var e = document.createElement('script'); e.async = true;
    e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
    document.getElementById('fb-root').appendChild(e);
    }());
    </script>
    </div>

    And I'm basically including this on every tutorial page so that people can comment. Obviously, each page is unique and I want a different instance of comments. How can I make the ID's different for each page while using a PHP include? I would rather not go and post this on every page I have as it would take a while, and I'd like to be edit to edit easily in the future
     
  2. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #2
    set a variable with the id before including the file
    $my_id="THIS_IS_YOUR_ID"; 
    Code (markup):
    then

    FB.init({appId: <?php echo $my_id; ?>, status: true, cookie: true,
    xfbml: true});
    Code (markup):
     
    n3r0x, May 1, 2010 IP