0

I have a Tumblr site where I can edit the HTML and CSS. They have this variable which is called {Permalink} which refers to the current post's link.

Since PHP is not allowed, I had to host a script externally and put it in my site through an iframe. The problem is that the script contains this:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="YOUR URL" num_posts="1" width="460"></fb:comments> 

where I would like to replace "YOUR URL" with {Permalink}. Since the PHP file is hosted externally it wouldn't work. So what I'm looking for is to put a undefined variable there, and define that variable through my iframe, like so:

<iframe src="my.php" width: "460" data-urlvariable: "{Permalink}"></iframe>

and in my .php file:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="$_data-urlvariable" num_posts="1" width="460"></fb:comments> 

I figured the php GET method would do the job, but I'm not so sure how to use it in a <div><script>. So is there a way to define a variable within my tumblr site and put it in my externally hosted php file?

Anyway here's part of the .php file.

   <head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
   </head>
   <body>
         <div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:comments href="YOUR URL" num_posts="1" width="460"></fb:comments>

         <div style="visibility:hidden">
         <?php

$STD_PATTERN = "<img src='@@userpicture@@'/><a href='@@userlink@@'>@@username@@</a> <BR> @@message@@ <BR> @@formatteddate@@<HR>";

/* PLEASE DON'T MODIFY THE CODE BELOW THIS COMMENT */
class SEO_FBComments {
    const GRAPH_COMMENTS_URL = "https://graph.facebook.com/comments/?ids=";

    private $pattern;
    private $pageUrl;
4

1 回答 1

0

也许有更多 Tumblr 经验的人可以在这里插话,但我很确定这{Permalink}是由 Smarty(或类似)模板引擎解析的。在这种情况下,由于模板变量(内部的单词{})来自服务器端,因此无法在<iframe>其他地方托管它们。

然而,一切都没有丢失。您可以{Permalink}使用 JavaScript(或 jQuery)获取值并将其保存为客户端 JavaScript 变量,然后将该变量的数据弹出到您的 PHP 调用中<iframe>

于 2013-07-06T00:53:15.560 回答