We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10395
    • 96 Posts
    Doesn’t display anything, I already have the $output being returned:

    echo "Echo: ".$rssResultLink;
    
    	$output = $modx->getChunk('myChunk',array(  
      'myRssLink' => $rssResultLink
    ));
    
      return $output;


    I simply have the echo there to make sure I’m not crazy and the var isn’t really empty.
      • 3749
      • 24,544 Posts
      Try

      $modx->setPlaceholder('myRssLink',$rssResultLink);


      before the getChunk() call.

      Be sure the placeholder is [[+myRssLink]].


      If that doesn’t get you any output, I’d be looking at the chunk in the database (modx_site_htmlsnippets), to see if there’s anything odd about it.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 10395
        • 96 Posts
        Thank you!! That did work perfect smiley. Though, seems kind of weird to first declare the variable placholder, then declare the same exact variable when you use getChunk. This is what worked:

        	      //Assign the data
        	      $modx->setPlaceholder('rssUrl',$xml->channel->item[$i]->link);
                      $modx->setPlaceholder('rssTitle',$truncTitle);
                      $modx->setPlaceholder('rssTitleHover',$xml->channel->item[$i]->title); 
        
        	//Output it via the chunk
        $output .= $modx->getChunk('rssListResults',array(  
          'rssUrl' => $xml->channel->item[$i]->link,
          'rssTitle' => $truncTitle,
          'rssTitleHover' => $xml->channel->item[$i]->title
           	));
          
           }
        		return $output;
        
          • 3749
          • 24,544 Posts
          Yeah, your whole case is kind of weird. wink

          If you set the placeholders individually, you should leave out the second argument to getChunk().

          To satisfy my curiosity, would you try this code:
          $fields = array(  
            'rssUrl' => $xml->channel->item[$i]->link,
            'rssTitle' => $truncTitle,
            'rssTitleHover' => $xml->channel->item[$i]->title
             	));	
          
          $modx->toPlaceholders($fields);   
          
          
          $output .= $modx->getChunk('rssListResults');
            
          return $output;



            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 10395
            • 96 Posts
            Yeah, it’s quite the odd issue tongue.

            Tried the code, didn’t seem to work:

            $fields = array(  
              'rssUrl' => $xml->channel->item[$i]->link,
              'rssTitle' => $truncTitle,
              'rssTitleHover' => $xml->channel->item[$i]->title
               	);	
            
            $modx->toPlaceholders($fields);   
            
            
            $output .= $modx->getChunk('rssListResults');
               
            


            Funny thing is though, just to add to the weirdness, $truncTitle (rssTitle) displays fine. The two $xml calls don’t (rssUrl and rssTitleHover). Even though ultimately, $truncTitle is just an $xml call that was cut back a few characters and stuck into another variable.
              • 28215
              • 4,149 Posts
              It’s because you’re taking a SimpleXML object and storing it as a placeholder; when using SimpleXML, you need to explicitly cast attributes as strings:

              $fields = array(  
                'rssUrl' => (string)$xml->channel->item[$i]->link,
                'rssTitle' => $truncTitle,
                'rssTitleHover' => (string)$xml->channel->item[$i]->title
              );	
              $modx->toPlaceholders($fields);   
              $output .= $modx->getChunk('rssListResults');
              


              or in the original snippet:

              $data = array(
                   'rssUrl' => (string)$xml->channel->item[$i]->link,
                   'rssTitle'  => $truncTitle,
                   'rssTitleHover' => (string)$xml->channel->item[$i]->title,
              );
              $output .= $modx->getChunk('rssListResults',$data);
              

                shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
                • 3749
                • 24,544 Posts
                Makes sense. I assumed that they were strings to begin with.
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting