We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36782
    • 109 Posts
    Hi there,

    This is baffling me, and it's not the first time.
    I'm using modx 2.2.4, on XAMPP, windows 7; but I have seen it happen on about 6 different setups, so it is obviously something I am doing wrong.

    I am using this snippet:
    <?php
    $output='';
    $c = $modx->newQuery('modResource');
    $c->where(
    	array(
    		'published' => true,
    		'deleted' => false,
    	)
    );
    if (count($ids) > 0) {
    	$c->where(
    		array(
    			"`id` IN (".$ids.")",
    		)
    	);
    	$c->sortby('menuindex','ASC');
    	$c->limit($limit);
    	$resources = $modx->getCollection('modResource',$c);
    
    	foreach ($resources as $resource) {
    		$resourceArray = array();
    		$resourceArray['id']=$resource->get('id');
    		$resourceArray['title']=$resource->get('longtitle');
    		$resourceArray['description']=$resource->get('description');
    		$resourceArray['Thumbnail'] = $resource->getTVValue('Thumbnail');
    		$output .= $modx->getChunk($tpl,$resourceArray);
    	}
    	return $output;
    }
    to pull GalleryItem type TVs from resources, using this template:
    <a href="[[~[[+id]]]]" title="[[+title]]" class="featured-project-image">[[+Thumbnail]]</a>

    As you can see, I've stripped out everything except the link and the image.
    Here is the snippet call:
    <div id="featured-projects-bg">[[getThumbnails? &ids=`[[*Portfolio Items]]` &limit=`5` &tpl=`Tpl.thumbnail`]]</div>
    wrapped in its div so you can see that there is no "


    " in there.

    And that is the problem, I am getting a set of double quotes and 2 lines of empty space before the snippet tpl output.
    I have seen this before, as I mentioned, and have tried to just ignore it, but I would really like to know if it can be solved?

    Oh, the TV type is from the Gallery component, available in the repo. It is todays version.

    thnx for any advice -- including "your snippet sux", 'cause I would like to know if it's a really bad implimentation.

    -g [ed. note: unsub777 last edited this post 14 years, 3 months ago.]
      • 3749
      • 24,544 Posts
      Check to see if magic_quotes_gpc is enabled on the server.


      ------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using.
      MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 3 months ago.]
        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
        • 36782
        • 109 Posts
        hello,
        no, it's off.
        stumped.

        but on the bright side, now I have some notion of what magic_quotes are. smiley
          • 3749
          • 24,544 Posts
          Could any of the code have been mangled by a rich-text editor or Code Mirror?

          I would try pasting the code into something lame like NotePad and then pasting it back (or just deleting and retyping it with richtext turned off).

          If that doesn't do it, try looking at the rendered page in FireBug and see if that gives you any clues. It could be something in your CSS file, or some wayward JS on the page.


          ------------------------------------------------------------------------------------------
          PLEASE, PLEASE specify the version of MODX you are using.
          MODX info for everyone: http://bobsguides.com/modx.html
            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
            • 36782
            • 109 Posts
            hi
            still got the emtpy quotes.
            Although interestingly enough after pasting and resaving in notepad++ the extra lines disappeared.
            So just "" now, without the lines. This is more what I have seen in most of my Modx sites.

            Unfortunately I'm not using richtext in my elements, as much as I'd like to have some kind of formatting / tab ability in there.
              • 3749
              • 24,544 Posts
              Sorry, I don't know what could cause that, but I haven't used Gallery for a long time.


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                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
                • 36782
                • 109 Posts
                Hi
                I've taken Gallery out of the site now. But, as I suspected, it seems to be nothing to do w/ Gallery.

                Here is a picture of Chrome's inspector showing the extra stuff:


                I am not pulling any content here. The output is from a snippet (very similar to above). So it can't be a richtext thing.
                  • 3749
                  • 24,544 Posts
                  That's truly odd. I would try deleting and retyping that part of the Tpl chunk, if you haven't already.

                  If that doesn't do it, try editing that field in the DB with PhpMyAdmin. It should be in the modx_htmlsnippets table if it's a chunk. While you're there, you might as well repair all the tables in the DB.


                  What's the Input type and Output type of the Thumbnail TV, and what is its content?



                  ------------------------------------------------------------------------------------------
                  PLEASE, PLEASE specify the version of MODX you are using.
                  MODX info for everyone: http://bobsguides.com/modx.html
                    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
                    • 36782
                    • 109 Posts
                    Hi
                    The Thumbnail TV is an image. I've changed the snippet because the GalleryItem tv is broken; now I'm just making my own galleries using MigX, so i'm pulling the first image in each set as a "Thumbnail" for the content item:
                    <?php
                    $output='';
                    $c = $modx->newQuery('modResource');
                    $c->where(
                    	array(
                    		'published' => true,
                    		'deleted' => false,
                    	)
                    );
                    if (count($ids) > 0) {
                    	$go = TRUE;
                    	$c->where(
                    		array(
                    			"`id` IN (".$ids.")",
                    		)
                    	);
                    	$c->sortby('menuindex','ASC');
                    	$c->limit($limit);
                    	$resources = $modx->getCollection('modResource',$c);
                    
                    	foreach ($resources as $resource) {
                    		//GET json string von the migx tv
                    		$json_output = $modx->fromJson($resource->getTVValue('Album'));
                    		// init res.arr.
                    		$resourceArray = array();
                    		// populate res.arr.
                    		$resourceArray['id']=$resource->get('id');
                    		$resourceArray['title']=$resource->get('longtitle');
                    		$resourceArray['description']=$resource->get('description');
                    		$resourceArray['Thumbnail'] = $json_output[0]['image'];
                    		
                    		$output .= $modx->getChunk($tpl,$resourceArray);
                    	}
                    	return $output;
                    }

                    Thank you for the advice, I will give that a try. It really is wierd. I've seen it before with getResources, and a couple other things, but it never caused me the trouble it's causing now, so I always just ignored / worked around it. This time it's really messing up my templating.
                      • 3749
                      • 24,544 Posts
                      Image TVs can be weird. You didn't really answer my question about the input type and output type settings. With some settings, MODX will try to render a full img tag, so if your Tpl also has an img tag, you can get strange results.



                      ------------------------------------------------------------------------------------------
                      PLEASE, PLEASE specify the version of MODX you are using.
                      MODX info for everyone: http://bobsguides.com/modx.html
                        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