|
chucky
|
 |
« on: Dec 24, 2005, 10:14 AM » |
|
hi ! i have a little problem with equal signs in snippets for example, this very simple snippet: [[test]] return $var;
if i use [!test? &var=something=test!] the snippet will only return "something", it will stop right before the equal signs what do i have to do to "protect" the equal signs  thanks ( i'm a php noob ) my config modx 0.9.1 php 4.4.1 ( full details about my php config http://60gp.ovh.net/test.php ) mysql 4.0.17 ( it's a unix server )
|
|
|
|
|
Logged
|
i'm not a native english speaker, sorry if there are any mistakes ! Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
|
|
|
rthrash
Foundation

Posts: 9,269
|
 |
« Reply #1 on: Dec 24, 2005, 11:01 AM » |
|
Place the variables inside backtics (`) and see if that helps. On english keyboards, that's the key to the left of the top-row 1.
|
|
|
|
|
Logged
|
MODx is a framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Community participation and questions are encouraged, especially when you help us help you, read the wiki, and review snippet parameters – even if you have to look at the source. Searching the forums helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.
|
|
|
|
chucky
|
 |
« Reply #2 on: Dec 24, 2005, 11:10 AM » |
|
i just tried with [!test? &var=`something=test`!] the problem is still there ..., by the way do u have the same problem ?
( i use modx in french, with the utf-8 charset, maybe it's language/font related ? ) edit : i also tried in ISO-8851 and in english, this bug is not language, charset encoding related ...
thanks for your help
|
|
|
|
« Last Edit: Dec 24, 2005, 11:21 AM by chucky »
|
Logged
|
i'm not a native english speaker, sorry if there are any mistakes ! Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
|
|
|
vbrilon
Coding Team

Posts: 256
|
 |
« Reply #3 on: Dec 24, 2005, 11:21 AM » |
|
I think the current parser translates any '=' as a literal and uses that for assignment. Can you enter a bug/enchancement request please to allow the escaping of it and to be used as a literal character?
As a work around, maybe you can write your snippet like this: [!test? &var=something**test!]
And then in your snippet code, replace the '**'(or whatever chars you want to use) with '='
|
|
|
|
|
Logged
|
|
|
|
|
chucky
|
 |
« Reply #4 on: Dec 24, 2005, 11:27 AM » |
|
i will enter a bug request,
about the ** ==> = replacement ,i'm a php newbie, i just started readings some docs a few days ago, and i don't know much about regex yet ..., maybe you would know how to do that ? ) thx
|
|
|
|
« Last Edit: Dec 24, 2005, 11:33 AM by chucky »
|
Logged
|
i'm not a native english speaker, sorry if there are any mistakes ! Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
|
|
|
zi
MODx Special Forces /
Administrator

Posts: 2,941
May Peace Be On You
|
 |
« Reply #5 on: Dec 24, 2005, 12:31 PM » |
|
Hi chunky, Please use http://modxcms.com/bugs/ to log this and all future Bugs/Feature requests. thanks, zi
|
|
|
|
|
Logged
|
“Internet Explorer’s CSS rendering: WYSIWTF”. — someone genius
--------------------------------------------------
|
|
|
vbrilon
Coding Team

Posts: 256
|
 |
« Reply #6 on: Dec 24, 2005, 02:06 PM » |
|
i will enter a bug request,
about the ** ==> = replacement ,i'm a php newbie, i just started readings some docs a few days ago, and i don't know much about regex yet ..., maybe you would know how to do that ? ) thx
Let me answer that with a question  Why do you need a literal '=' passed into the snippet? Can you give me an example (don't need the actualy code, just an explanation).
|
|
|
|
|
Logged
|
|
|
|
|
chucky
|
 |
« Reply #7 on: Dec 24, 2005, 05:41 PM » |
|
well i just made a snippet http://modxcms.com/forums/index.php/topic,1941.0.htmlwhich generates round boxes, example here http://wiki.jalakai.co.uk/dokuwiki/doku.php/test/boxesi use a variable for the content of the box, with just pure text it works fine, but i'd like to use html code for the box content. thanks bye >zi, sorry i thought the bug section of the forum was the place to report bugs
|
|
|
|
« Last Edit: Dec 24, 2005, 05:43 PM by chucky »
|
Logged
|
i'm not a native english speaker, sorry if there are any mistakes ! Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
|
|
|
vbrilon
Coding Team

Posts: 256
|
 |
« Reply #8 on: Dec 24, 2005, 08:20 PM » |
|
Now I am confused. The snippet takes key/value pairs normally (as it should). I don't understand why you need to pass a literal '=' into the snippet. Can you explain please?
BTW, I agree that it's a bug that an escaped '=' can't be passed in, not arguing that point. Just don't see what you're trying to accomplish with the syntax of: [!test? &var=something=test!]
That'll call the test snippet, and set 'var' to 'something'. Are you expecting it to set 'var' to 'something=test'?
|
|
|
|
|
Logged
|
|
|
|
Djamoer
Testers

Posts: 1,492
No one can limit a man other than the man himself.
|
 |
« Reply #9 on: Dec 24, 2005, 11:50 PM » |
|
Hi vbrillon, From what I understand, chucky wanting to pass html tag as the text into the snippet as well, which in html tag, there will be a text with equal sign on it, take an example from this example. [!test? &var=`<a href="index.htm"`!]
Hope that clarifies things up. Chucky, my suggestion for now, you can get into the snippet code, and change the php calling that parse the variables to fetch it from chunk. I'm not to for usre whether this will be a better solution for you or not. The other way is you can use TV and call up the TV value from the snippet, and this will help you if you need to use the snippet in every pages and every pages will have different value assign into the box. If you need s suggestion, feel free to post it in here, and explain it further of what you're trying to do. Hope all of the people in here able to help you with that. Merry Christmas...
|
|
|
|
|
Logged
|
|
|
|
vbrilon
Coding Team

Posts: 256
|
 |
« Reply #10 on: Dec 25, 2005, 02:05 AM » |
|
So I *still* don't understand why that snippet needs a literal '=' passed to it, but ok...let's move on  The easiest way to work around this is to use some text that you're guaranteed to never see otherwise and use that as a placemarker for the '='. An example might be easier. Call your snippet this way: [!test? &var=`<a hrefXXXX"index.htm"`!] Notice that 'XXXX' is used instead of a literal '='. Then in your snippet, the first thing you do is: $var = preg_replace('/XXX/','=',$var); Yes I agree it's an ugly hack, but it seems like a quick workaround until the real problem is fixed.
|
|
|
|
|
Logged
|
|
|
|
|
chucky
|
 |
« Reply #11 on: Dec 25, 2005, 03:34 AM » |
|
So I *still* don't understand why that snippet needs a literal '=' passed to it, but ok...let's move on  just because i need to pass html tags in the variables  , for example html links need equal signs ( href=... ) ( sorry my english isn't perfect :s ) wendy i didn't really understand what you meant, you suggest that i use a chunk within the snippet ? i think i'm gonna use the regex solution merry christmas !
|
|
|
|
|
Logged
|
i'm not a native english speaker, sorry if there are any mistakes ! Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
|
|
|
sottwell
Documentation Team

Posts: 8,142
|
 |
« Reply #12 on: Dec 25, 2005, 06:23 AM » |
|
Yes, pass the name of the chunk (&var=`ChunkName`), then in the snippet do $link = $modx->getChunk($var);
You can put whatever you want in the chunk, even including snippet tags!.
|
|
|
|
|
Logged
|
|
|
|
garethf
Jr. Member

Posts: 22
|
 |
« Reply #13 on: Jan 11, 2007, 05:24 AM » |
|
Using a chunk prevents truncation at a the equals sign, but not at a 'less than' sign.
I'm looking for a way to pass an SQL statement as a string variable, but both snippet variables and chunks seem to fail. Here's the string I'm trying to pass:
where LENGTH(Customer)=4 and Passed<NOW()
|
|
|
|
|
Logged
|
|
|
|
sottwell
Documentation Team

Posts: 8,142
|
 |
« Reply #14 on: Jan 11, 2007, 07:20 AM » |
|
There are two ways you can handle such issues. Either use a different symbol, and have a line in the snippet with a str_replace function to convert the symbol back to what you want, or create a second snippet that only has a call to runSnippet, with the values you want in the params array: return $modx->runSnippet('MySnippet', array('param1'=>'where LENGTH(Customer)=4 and Passed<NOW()', 'param2'=>'value2');
|
|
|
|
|
Logged
|
|
|
|
|