使用Get Data时不显示侧边栏

时间:2014-12-17 作者:shorif2000

我有一个侧边栏作为小部件,它根据超级页面id在所有页面上正确显示。我使用一个自定义函数来计算和显示所需的侧边栏。

    function is_tree($pid) {      // $pid = The ID of the page we\'re looking for pages underneath
    global $post;
    $postId = null;
    $ancestors = array();

    if(count($post)>1){
        $post = get_post(get_the_ID());
        $cat = get_the_category( get_the_ID() );
        //print_r($post);
        switch($cat[0]->name){
            case "Press Release":
                $postId = PAGE_ABOUT;
                break;
            default:
                $postId = "00000";
                break;
        }
        if($post->post_type == "event")
            $postId = PAGE_ABOUT;
        if($post->post_type == "technical_paper")
            $postId = PAGE_GEOLOGICAL;

    }else{
        $cat = get_the_category( get_the_ID() );
        if(isset($cat[0])){
            switch($cat[0]->name){
                case "Press Release":
                    $postId = PAGE_ABOUT;
                    break;
                case "Technical Paper":
                    $postId = PAGE_GEOLOGICAL;
                    break;
            }
        }
    }

    if($post){
        if($post->post_type == "job_listing")
            $postId = PAGE_CAREER;
        if($post->post_type == "event")
            $postId = PAGE_ABOUT;
        if($post->post_type == "technical_paper")
            $postId = PAGE_GEOLOGICAL;

        $ancestors = get_post_ancestors($post->$pid);
        $root = count($ancestors) - 1;
        $parent = $ancestors[$root];
    }   

    if( is_page() && (is_page($pid) || $post->post_parent == $pid || in_array($pid, $ancestors)) || ($pid == $postId) )
        return true;
    elseif( 5581 == $pid && $_REQUEST[\'ir\'] )
        return true;
    else
        return false;

}
使用widget logic 我在每个不同的侧边栏上使用调用此函数的插件is_tree(pid).

如果浏览到下一页,侧边栏将显示https://gateway.spectrumasa.com:10443/investors/investor-news/news-room/investor-news-story 但是,如果您浏览到下一页,则使用“获取数据”不会。

https://gateway.spectrumasa.com:10443/investors/investor-news/news-room/investor-news-story?ir=http://cws.huginonline.com/S/139450/PR/201411/1873983.xml.

我怎样才能解决这个问题。我对右侧边栏使用相同的方法。

内容是使用一个短代码显示的,该代码获取get数据并解析xml文件以生成输出。

if(!require_once("MagicParser.php")){
  echo "Please contact Support";

}else{

    $ir_url = $_GET[\'ir\'];    
    $filename = $ir_url;
}


  function myRecordHandler4($record)
  {
    print "<b>".$record["BODY/PRESS_RELEASES/PRESS_RELEASE/HEADLINE"]."</b> (";  
    print $record["BODY/PRESS_RELEASES/PRESS_RELEASE/PUBLISHED-DATE"].")";
    $tmp = $record["BODY/PRESS_RELEASES/PRESS_RELEASE/MAIN"];
    $tmp = str_replace("&nbsp;","",$tmp);
    $tmp = str_replace("please contact:","please contact:<br/>",$tmp);
    $tmp = str_replace("Olset","Olset<br/>",$tmp);
    $tmp = str_replace("Spectrum ASA","Spectrum ASA<br/>",$tmp);
    $tmp = str_replace("49 65","49 65<br/>",$tmp);


    print $tmp."<br />";
    //print str_replace("&nbsp;","",$record["BODY/PRESS_RELEASES/PRESS_RELEASE/MAIN"])."<br />";
  }

  function pageInvestmentResultA($record)
  {
    print "<a target=\'_new\' href=\'".$record["LOCATION-HREF"]."\'><b>".$record["FILE_HEADLINE"]."</b></a> ".$record["FILE-FORMAT"]."<br />";
  }
  if(!$filename)
    echo "No content found!";
  else{    
    MagicParser_parse($filename,"myRecordHandler4","xml|HEXML/");
    MagicParser_parse($filename,"pageInvestmentResultA","xml|HEXML/BODY/PRESS_RELEASES/PRESS_RELEASE/FILES/FILE/");
  }

1 个回复
SO网友:shorif2000

wordpress不喜欢文件扩展名。使用子字符串删除文件扩展名,然后再将其添加回。

结束

相关推荐

List sidebars on a page

我需要在给定页面上生成边栏列表。我知道如何列出所有已注册的侧栏,以及所有已注册的具有活动小部件的侧栏,但我不知道how to filter 他们一直到the sidebars that were displayed on an individual page 使用PHP。为了避开这个我$wp_registered_sidebars 并将其替换为实现ArrayAccess, 其中90%的方式是拦截调用并存储请求的侧栏,只有侧栏永远不会显示,因为某个地方是is_array 或其他检查失败。我也可以拦截dyna