We launched new forums in March 2019β€”join us there. In a hurry for help with your website? Get Help Now!
    • 30195
    • 10 Posts
    Ok, I have tried and tried...

    I am unable to get this to work....

    http://wiki.modxcms.com/index.php/Adding_TV_Widgets_without_hacking_the_core

    Can someone please test it and let me know if it’s just me?

    After adding the [!sideBarWidget!] to my template, all I get as a result it... [[sideBarWidget]]
      • 28042 β˜† A M B β˜†
      • 24,524 Posts
      Are you sure you have the name right? It will do that if the uppercase/lowercase or some other part of the snippet name does not exactly match.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 30195
        • 10 Posts
        ok, I might be getting closer. Yeah, I must have entered the tv name incorrectly.

        but NOW, the widget is printing only one character.... the second character ONLY! If I enter "Test" (in the sidebarTV field) it prints <div class="sidebarContent">e</div>

        If I enter 123, it prints... <div class="sidebarContent">2</div>!

        Any idea why?

        Thanks in advance!


        EDIT: I see it has to do with the array....


        changing

        
        <?php
        // sidebarWidget snippet
        // parameters:
        // &tvname - Set the TV name to be used, defaults to sidebarTV
        $TVname = isset($tv)?$tv:'sidebarTV'; 
        
        // fetch the output array of the TV
        if( $TVarray = $modx->getTemplateVarOutput(array($TVname)) ){
        	#TV output is in index [$TVname][1]
        	$tvOutput = $TVarray[$TVname][1];
        	if(empty($tvOutput)) return ''; //bail out if no value
        
        	// Here is where we can start customizing the output.
        	// For now, just return the TV output in a <div> container
        	return '<div class="sidebarContent">'.$tvOutput.'</div>';
        }
        return '';
        ?>
        
        


        to..


        
        <?php
        // sidebarWidget snippet
        // parameters:
        // &tvname - Set the TV name to be used, defaults to sidebarTV
        $TVname = isset($tv)?$tv:'sidebarTV'; 
        
        // fetch the output array of the TV
        if( $TVarray = $modx->getTemplateVarOutput(array($TVname)) ){
        	#TV output is in index [$TVname][2]
        	$tvOutput = $TVarray[$TVname][2];
        	if(empty($tvOutput)) return ''; //bail out if no value
        
        	// Here is where we can start customizing the output.
        	// For now, just return the TV output in a <div> container
        	return '<div class="sidebarContent">'.$tvOutput.'</div>';
        }
        return '';
        ?>
        
        


        changes the 2 to a 3 (if I enter 123 - SO, that must be where I put a regular expression? And if so, how would I print EVERYTHING?)
          • 30195
          • 10 Posts
          Voila.... this guy is having the same problem....

          http://modxcms.com/forums/index.php/topic,22885.0.html
            • 7231
            • 4,205 Posts
            I think that there are some issues with the way you are accessing the arrays, try it like this:
            <?php
            // sidebarWidget snippet
            // parameters:
            // &tvname - Set the TV name to be used, defaults to sidebarTV
            $TVname = isset($tv)?$tv:'sidebarTV'; 
            
            // fetch the output array of the TV
            if( $TVarray = $modx->getTemplateVarOutput($TVname)){
            	#TV output is in index [$TVname]
            	$tvOutput = $TVarray[$TVname];
            	if(empty($tvOutput)) return ''; //bail out if no value
            
            	// Here is where we can start customizing the output.
            	// For now, just return the TV output in a <div> container
            	return '<div class="sidebarContent">'.$tvOutput.'</div>';
            }
            return '';
            ?>
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]