Oct 13, 2008, 02:05 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1]   Go Down
  Print  
Author Topic: Usage of the &save parameter and [+_ditto_object+]  (Read 733 times)
0 Members and 1 Guest are viewing this topic.
The Man Can!
Testers
*
Posts: 282



WWW
« on: May 02, 2008, 03:54 PM »

Is there any additional information on using the save parameter?
I'm trying to use PHx to say, "If Ditto has output, then do this, else do something else", but the [+dittoid_ditto_object+] and [+dittoid_ditto_resource+] placeholders don't seem to return anything, regardless of which save mode I try.

I'm assuming that it's because it's a placeholder for the object itself and not the output of the Ditto call, but is there a way to get Ditto to actually output to a placeholder? I could have sworn there was, but I'm not seeing anything in the code or docs other than the save parameter.

Thanks for any ideas.
Logged

Need MODx Ecommerce? Try FoxyCart!
heliotrope
Coding Team
*
Posts: 2,412


WWW
« Reply #1 on: May 02, 2008, 05:11 PM »

Hi Brett,

you can use the [+total+] placeholder instead.

[+total:isnot=``:then=``+]

:-)
Logged

The Man Can!
Testers
*
Posts: 282



WWW
« Reply #2 on: May 02, 2008, 05:40 PM »

Thanks for the response, Heliotrope. I wouldn't have thought of that. In case anybody else needs this, keep in mind you'll need to add &paginate=`1` and &paginateAlwaysShowLinks=`1` to your ditto call to get the [+total+] to show up.

So that takes care of the bigger issue, but as far as the actual Ditto output going to a placeholder, is that possible? Without some way to output to a placeholder I'd need to duplicate the Ditto call, which isn't the end of the world, but I'd rather not if it's avoidable.
Code:
[[Ditto? &parents=`39` &tpl=`event_link_mini` &display=`100` &id=`seminars` &sortBy=`date_start` &sortDir=`ASC` ]]
[+phx:if=`[+seminars_total+]`:ne=``:then=`
<div class="container">
<h2 class="h1">Seminars</h2>
[+seminars_ditto_object+] <!-- Ditto call would have to be duplicated here -->
</div>
`+]

EDIT: Yeah, outputting to a placeholder is definitely gonna be useful, or the first ditto call (that generates the +total+ placeholder, needs to have its output hidden with CSS or commented out or something...

EDIT 2: I know this could be accomplished with a format config file, but I'd rather avoid that for a few reasons.
« Last Edit: May 02, 2008, 05:52 PM by The Man Can! » Logged

Need MODx Ecommerce? Try FoxyCart!
Jesse R.
Coding Team
*
Posts: 775


WWW
« Reply #3 on: May 02, 2008, 07:45 PM »

I do not believe you can make use of those placeholders unless you set &save to something besides its default value of 0.  For instance:

Code:
[[Ditto? &parents=`39` &tpl=`event_link_mini` &display=`100` &id=`seminars` &sortBy=`date_start` &sortDir=`ASC` &save=`1`]]

You can find more information here:

http://ditto.modxcms.com/files/snippet-ditto-php.html#save
« Last Edit: May 02, 2008, 07:50 PM by Jesse R. » Logged

Jesse R.
Consider trying something new and extraordinary.
Illinois Wine

Have you considered donating to MODx lately?
Donate now.  Every contribution helps.
The Man Can!
Testers
*
Posts: 282



WWW
« Reply #4 on: May 02, 2008, 08:04 PM »

Right, but regardless the value (1, 2, 3) the placeholders don't generate anything. At least, not for me.

The code I pasted above was the workaround, since I can't get &save to actually do anything (except not output anything).
The Ditto code actually replaces [+ _ditto_object+] with $ditto itself, the entire Ditto object, not the output, so I think that's why it's not replacing the placeholder with the output (unless I'm missing something about the makeup of the $ditto object itself).

At this point I've worked around the issue with the [+total+] idea and commenting out the first Ditto call's output, but I'm still kind of curious if it's possible.
Logged

Need MODx Ecommerce? Try FoxyCart!
Jesse R.
Coding Team
*
Posts: 775


WWW
« Reply #5 on: May 02, 2008, 09:30 PM »

It would have probably helped if I reread your original post after looking at ditto and seeing that you quite clearly were talking about what I mentioned Grin.  Now let's see if I can be of a little help.  I do not think Ditto places its output in a placeholder.  However, have you considered coding your own snippet to do exactly what you are looking to do?  Something like this:

Code:
<?php

$dittoParams
= array(
'parents' => '39',
'tpl' => 'event_link_mini',
'display' => '100',
'sortBy' => 'date_start',
'sortDir' => 'ASC',
'id' => 'seminars'
                    
);

$dittoOutput = $modx->runSnippet('Ditto', $dittoParams);

if (
$dittoOutput != '') {
    return
THIS;
} else {
    return
THIS;
}

?>

« Last Edit: May 02, 2008, 10:06 PM by Jesse R. » Logged

Jesse R.
Consider trying something new and extraordinary.
Illinois Wine

Have you considered donating to MODx lately?
Donate now.  Every contribution helps.
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!