0

I have a sidebar as a widget which displays correctly on all pages depeneding on the super page id. I am using a custom function to calculate and display the required sidebar.

    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;

}

Using widget logic plugin i called this function on each different sidebar using is_tree(pid).

If you browse to following page the sidebar will show https://gateway.spectrumasa.com:10443/investors/investor-news/news-room/investor-news-story however with get data if you browse to the following page it does not.

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

How can i solve this problem. I use the same method for the right sidebar.

The content is being displayed using a shortcode, which takes the get data and parses the xml file to produce the output.

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/");
  }
0

wordpress did not like the file extension. use substring to remove file extension and then add it back in later.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.