-
☆ A M B ☆
- 24,524 Posts
I am working over my "new" site to be as MODx as possible. This includes reworking all snippets to use the Properties tab. But I’m still not sure of how it works. Let’s take as an example Jason’s most excellent ListMenuX snippet that I will be using as my main menu generator.
Starting with line 19 we find:
$id = !isset($id)?$modx->documentIdentifier:$id;
$depth = !isset($depth)?0:$depth;
$nodiv = !isset($nodiv)?false:$nodiv;
$sDivId = empty($divId)?"":" id='$divId'";
$sDivClass = empty($divClass)?"":" class='$divClass'";
$sUlClass = empty($ulClass)?"":" class='$ulClass'";
$sLiClass = empty($liClass)?"":" class='$liClass'";
$sActiveLinkClass = empty($activeLinkClass)?"":" class='$activeLinkClass'";
If I understand correctly, these lines would all be removed, and these default values would be put in the Properties form instead? Will the $modx->documentIdentifier work the same in this case?
Yes the default properties would all be passed into the snippets.
The $modx->docmentIdentifier is a property of the MODx DocumentParer class and cannot not be replaced my default properties
-
☆ A M B ☆
- 24,524 Posts
So I can’t do like so: &id=Folder ID;int;$modx->documentIdentifier
Another dumb question: How do I do more than one? All in the same input field, separated by ... ?
Quote from: sottwell at Jul 29, 2005, 09:57 AM
So I can’t do like so: &id=Folder ID;int;$modx->documentIdentifier
Another dumb question:? How do I do more than one?? All in the same input field, separated by? ... ?
no, you can’t do this:
&id=Folder ID;int;$modx->documentIdentifier
but you can do this:
&id=Folder ID;int;0
where $id will then be passed with the value 0
For multiple properties just separate them using a space:
&id=Folder Id;int;0 &name=Name;string &color=Color;string;#FFCC00
-
☆ A M B ☆
- 24,524 Posts
Ok, got it, I think. Thanks! Will be back if I run into problems.
-
☆ A M B ☆
- 24,524 Posts
Hm. There are several items here that default to "" (empty string); it doesn’t seem to like that. It saved the first one (sDivID) with nothing after the second semicolon, and dumped the rest. So you can’t use null or empty values for defaults here? (no big deal, I just gave them all a default value, but it would be nice to be clear on this issue)
Consider this:
&name=Name;string;
The above will default to an empty string for $name
Now consider this:
&name=Name;string;mary
The above will now default to mary for $name
-
☆ A M B ☆
- 24,524 Posts
The problem was that it didn’t save the entries following the first one with a null string.
hmmmm,
did you save the snippet after making the changes?
-
☆ A M B ☆
- 24,524 Posts
Hitting Enter automatically saves it. I did it again, using ’’ (single quotes) and this time it saved them all. Perhaps I had a typo in the earlier attempt; this time I wrote the string out in my editor and copy/pasted it. Whether there was a typo earlier, or it just didn’t like the "" (double quotes) who knows. I’ll try it again next time I modify a snippet and see.