2012-01-09 17 views
0

我有一个传递的问题?和=通过我的网址,因为我使用Drupal(尽管我认为它不重要Drupal或静态网站)。Facebook的Colorbox URL参数Like

每个媒体内容的I型有需要本地主机/媒体/视频的路径?开放=?cbox10

Pathauto模块具有此对每个媒体资产内容类型。 媒体/视频?开放=?CBOX [NID]

节点网址,然后貌似 http://localhost/media-gallery/images%3Fopen%3D%3Fcbox14

让我知道,如果我错了,但我相信我现在需要编码/使用PHP解码网址。每个节点URL都需要直接打开视频页面上的颜色框。

我正在调查urlEncodeComponent,但不知道如何实现它。我想它会在我的page.tpl.php中,并且只要这些字符出现就被解码。

我可能可以编码URL的值在我的jQuery或PHP?

如果有人有我不使用的路径自动模块的知识,请让我知道。我已经尝试'不替换'我的别名url中的特定字符,但它没有按预期工作,因为它仍然显示解码。

我需要这个URL编码为了传递正确的链接打开我的网页上的每个独特的内容的图标签。

目前有这样的显示每个视频资源页:??

<meta property="og:url" content="http://localhost/media- 
gallery/images%3Fopen%3D%3Fcbox14" /> 

需要被编码为媒体/视频开放= cbox14

jQuery来直接根据独特的资产ID打开彩盒

// Colorbox direct linking 
    // Get the cb id in url or set false if not found 
    var colorboxId = (window.location.href.indexOf('open=')==-1) ? 
     false : 
     window.location.href.slice(window.location.href.indexOf('open=') + 'open='.length + 1).split('&')[0]; 

    // Instantiate all colorboxes on the page 
    $(".colorbox-inline").colorbox(); 

    // If id of colorbox was sent in url, open it now 
    if(colorboxId !== false) { 
    $("#" + colorboxId).colorbox({open:true}); 
    } 

目前正在测试...不起作用:

<script> 

$(document).ready(function() { 
    var ogurl = $('meta[property="og:url"][content]').prop("content"); 

     $(ogurl).prop("content", 
      decodeURIComponent(ogurl); 
}); 


    </script> 

它适用于这是什么,但我如何确保我的网址编码正确,以便Facebook og:url可以拿起解码的网址。

非常感谢!

+0

有没有人有想法? – arkjoseph 2012-01-10 00:45:24

+0

谢谢micha,很清楚。你能告诉我如何使这更加动态化,这样我就不必每次添加新页面时添加新的js。我将尝试将元属性og url指定给var,而不是绝对路径,var将取代它的位置。 – arkjoseph 2012-01-10 18:26:53

回答

1

如果你是用PHP编写的,你最好还是用PHP解码。

echo '<meta property="og:url" content="' . urldecode("http://localhost/media- 
gallery/images%3Fopen%3D%3Fcbox14") . '" />'; 

否则使用jQuery,但我不知道这是可以做到因为Facebook也执行JavaScript和你也许应该对其进行修改(例如,点击事件)。

$('meta[property="og:url"][content]').each(function() { 
    $(this).prop("content", decodeURIComponent($(this).prop("content"))); 
}); 
+0

我怎样才能实现我的模板头以上的PHP? – arkjoseph 2012-01-12 15:27:15

+0

取决于CMS只是尝试它。 – noob 2012-01-13 07:20:49